5 min read
ā¢Question 17 of 49easyHow to Embed Audio and Video?
Native multimedia in HTML5.
What You'll Learn
- Video and audio elements
- Key attributes
- Multiple format support
Native Multimedia
HTML5 introduced <audio> and <video> elements for native multimedia without plugins like Flash.
Key Attributes
| Attribute | Purpose |
|---|---|
controls | Shows play/pause/volume |
autoplay | Starts automatically (often blocked) |
muted | Starts muted |
loop | Repeats playback |
poster | Video thumbnail |
Video Examples
index.htmlHTML
<!-- Video with controls -->
<video controls width="640" poster="thumbnail.jpg">
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm">
Your browser doesn't support video.
</video>
<!-- Autoplay muted (for autoplay to work) -->
<video autoplay muted loop playsinline>
<source src="background.mp4" type="video/mp4">
</video>Audio Examples
index.htmlHTML
<!-- Audio player -->
<audio controls>
<source src="song.mp3" type="audio/mpeg">
<source src="song.ogg" type="audio/ogg">
Your browser doesn't support audio.
</audio>Format Support
- Video: MP4 (widest), WebM, Ogg
- Audio: MP3, WAV, Ogg
Provide multiple formats for browser compatibility.