HTML Video
The <video> element is used to embed video content in a webpage. It supports multiple formats such as MP4, WebM, and Ogg. The <video> tag allows you to control the playback of the video, such as playing, pausing, and adjusting volume.
Basic Video Embedding
The basic syntax for embedding a video in HTML is:
<video src="path/to/video.mp4"></video>
Example of a Simple Video
<video src="video.mp4"></video>
Video with Controls
The <video> element can include the `controls` attribute to display built-in playback controls, such as play, pause, and volume control:
<video src="video.mp4" controls></video>
Multiple Video Formats
To ensure maximum compatibility across different browsers, you can provide multiple video formats within the <video> tag using multiple `
<video controls>
<source src="video.mp4" type="video/mp4">
<source src="video.ogg" type="video/ogg">
<source src="video.webm" type="video/webm">
Your browser does not support the video tag.
</video>
Autoplay and Loop
You can use the `autoplay` attribute to automatically start the video when the page loads. The `loop` attribute will make the video start again automatically after reaching the end:
<video autoplay loop controls>
<source src="video.mp4" type="video/mp4">
<source src="video.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
Muted Video
You can mute a video by adding the `muted` attribute:
<video muted controls>
<source src="video.mp4" type="video/mp4">
<source src="video.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
Video Accessibility
It's important to ensure that your video content is accessible. You can provide subtitles using the `
<video controls>
<source src="video.mp4" type="video/mp4">
<track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English">
Your browser does not support the video tag.
</video>