Chapter - 6 HTML Media: Embedding Videos, Audio, and More
Why HTML Media Matters
Webpages today deliver more than just text and images—they play music, show reels, host podcasts, and more.
Early web pages needed clunky plugins (like Flash), but now HTML5 lets us embed audio and video natively, across all modern browsers, using tags like <video> and <audio>.
Same key attributes work: autoplay, loop, muted, and preload (controls how soon the sound is downloaded).
Making Video and Audio Work for Everyone (Compatibility)
Not all browsers support all media formats!
Chrome/Firefox: prefer .webm
Safari: prefers .mp4
Some support .ogg (older, open format)
Use multiple <source> elements inside your tag:
Example:
<video controls>
<source src="clip.webm" type="video/webm">
<source src="clip.mp4" type="video/mp4">
Sorry, your browser does not support embedded videos.
</video>
The browser picks the first format it can play.
The fallback text appears if none are supported.
Accessibility: The
Add subtitles, captions, and descriptions for broader access:
Why? If you try to write < or > directly, the browser thinks you're starting or ending an HTML tag. Entities show these as actual characters, not code.