Last Updated : 23 Jul, 2025
Web design often has a feature of including a video that starts to play as soon as the web page loads. This effect can be achieved using HTML5 <video> element with the autoplay attribute. In this way, videos start playing without any user interaction hence improving the multimedia experience on websites.
Approach<video autoplay controls>
<source src="video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
Example 1: The example below shows how to add an autoplay video in HTML. The <video>
tag includes the autoplay
and controls
attributes, enabling the video to start playing automatically with user controls for playback.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content=
"width=device-width, initial-scale=1.0">
<title>Autoplay Video With Control Example</title>
</head>
<body>
<h2 style="color: green">GeeksforGeeks</h2>
<h3> How to add Autoplay Video With Control </h3>
<video autoplay controls>
<source src=
"https://media.geeksforgeeks.org/wp-content/uploads/20240517010406/Autoplay-Video-2.mp4"
type="video/mp4">
Your browser does not support the video tag.
</video>
</body>
</html>
Output:
Example 2: The example below shows how to add an autoplay video in HTML with the muted
attribute. The <video>
tag includes autoplay
and muted
attributes, enabling the video to start playing automatically without sound.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content=
"width=device-width, initial-scale=1.0">
<title>Autoplay Video WithOut Control Example</title>
</head>
<body>
<h2 style="color: green">Autoplay Video Example</h2>
<h3> How to add Autoplay Video WithOut Control </h3>
<video autoplay muted>
<source src=
"https://media.geeksforgeeks.org/wp-content/uploads/20240517010406/Autoplay-Video-2.mp4"
type="video/mp4">
Your browser does not support the video tag.
</video>
</body>
</html>
Output:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4