Welcome to Episode 10 of the Learn HTML series! In this episode, we'll learn how to embed and control video content using the <video> tag in HTML.
By the end of this episode, you'll be able to:
- Embed videos using the
<video>tag - Use various attributes to enhance user experience
- Provide fallback content for unsupported browsers
The <video> tag allows you to embed video files into a web page. You can also include multiple source formats for better browser compatibility.
<video controls>
<source src="movie.mp4" type="video/mp4" />
<source src="movie.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video>| Attribute | Description |
|---|---|
src |
Path to the video file |
controls |
Displays default play, pause, volume UI |
autoplay |
Starts video automatically (muted required) |
loop |
Repeats video after it ends |
muted |
Mutes the video by default |
poster |
Image to show before the video plays |
preload |
Preloading behavior for video |
<video width="600" controls poster="thumbnail.jpg">
<source src="video.mp4" type="video/mp4" />
<source src="video.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video>- Provide multiple formats (e.g.,
.mp4,.ogg) for compatibility - Use the
posterattribute for a better preview - Avoid
autoplaywithoutmuted(most browsers block it) - Always include fallback text for older browsers
- The
<video>tag embeds video files and offers built-in controls - Use attributes like
controls,poster, andmutedto improve user experience - Add multiple
<source>elements for format support
➡️ Episode 11: Working with Audio using <audio> Tag
Let’s add sound to our web pages! In the next episode, we’ll learn how to use the <audio> tag to play music or sound effects with full control. 🎧🔊