The HTML <video> element is used to embed video files directly into a web page without needing external plugins. It supports multiple formats and includes built-in playback controls.
<video src="movie.mp4" controls></video>
| Attribute | Description |
|---|---|
| src | Specifies the path/URL of the video file |
| controls | Displays play, pause, volume, and seek controls |
| autoplay | Starts playing the video automatically |
| loop | Replays the video continuously |
| muted | Starts the video without sound |
| poster | Displays an image before the video starts |
| width / height | Sets video dimensions |
| preload | Defines how the browser loads video (auto, metadata, none) |
Using <source> ensures better compatibility across browsers:
<video controls width="500">
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
Your browser does not support the video tag.
</video>
You can add captions or subtitles:
<video controls>
<source src="movie.mp4" type="video/mp4">
<track src="subs.vtt" kind="subtitles" srclang="en" label="English">
</video>
Browsers allow autoplay only if the video is muted:
<video autoplay muted loop>
<source src="banner.mp4" type="video/mp4">
</video>
<figure>
<video controls width="400">
<source src="clip.mp4" type="video/mp4">
</video>
<figcaption>Sample demonstration video</figcaption>
</figure>