This episode breaks down rich media: audio and video with built-in controls, the source element for format fallbacks, and picture for responsive images based on device conditions.

Modern pages contain more than text and still images. Episode 11 covers additional media elements: audio for sound, video for moving pictures, picture for images that adapt to device conditions, and source for providing several formats at once.
One important concept that recurs throughout this episode: fallback. A browser that doesn't support one format will try the next one. Correct structure ensures media keeps working on as many devices as possible.
audio plays sound with the built-in controls the browser provides:
<audio controls preload="metadata" src="media/sambutan.mp3">
Browser kalian tidak mendukung pemutar audio.
</audio>Commonly used attributes:
controls: displays play, volume, and progress buttons.preload: sets the loading strategy; the metadata value only loads brief information.loop and muted: boolean attributes for repeating and muting.The text between the opening and closing tags is a fallback — shown if the audio element isn't supported. This rule applies to all media elements.
Audio codecs are supported differently across browsers. Use source to provide alternatives:
<audio controls>
<source src="media/sambutan.mp3" type="audio/mpeg">
<source src="media/sambutan.ogg" type="audio/ogg">
Browser kalian tidak mendukung pemutar audio.
</audio>The browser picks the first source whose format it supports. Order them from the most efficient format.
video plays moving pictures, usually with controls and additional attributes:
<video controls width="640" preload="metadata" poster="media/poster.jpg">
<source src="media/intro.mp4" type="video/mp4">
<source src="media/intro.webm" type="video/webm">
Browser kalian tidak mendukung pemutar video.
</video>poster: the image shown before the video plays.width and height: player dimensions, preventing layout jumps.muted and loop: boolean attributes.Don't use autoplay with sound — browsers block it and it's a bad experience for users. autoplay is only acceptable together with muted.
Before embedding media, check the file format from the terminal:
ffprobe media/intro.mp4The command ffprobe media/intro.mp4 shows the codec, resolution, and duration. Make sure the dimensions match the width and height values you write.
source is an empty element used inside audio, video, and picture. On audio and video, the src and type attributes define the format; the browser picks the first one it supports.
The type attribute matters: it holds a MIME type like video/mp4 or audio/ogg, so the browser can filter formats without downloading them first.
picture gives the browser several image sources and picks one based on media queries or format support:
<picture>
<source srcset="foto/pemandangan.avif" type="image/avif">
<source srcset="foto/pemandangan.webp" type="image/webp">
<img src="foto/pemandangan.jpg" alt="Pemandangan pegunungan" width="800" height="500">
</picture>The flow: if the browser supports AVIF, use that file; if not, try WebP; and the img at the end is always the fallback that's guaranteed to work. Key rule: picture must always contain an img element as its last child — that's where alt is written.
Combine audio and video in one page:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Media Center</title>
</head>
<body>
<h1>Media Center</h1>
<h2>Podcast Sambutan</h2>
<audio controls preload="metadata">
<source src="media/sambutan.mp3" type="audio/mpeg">
Browser kalian tidak mendukung pemutar audio.
</audio>
<h2>Video Pengenalan</h2>
<video controls width="640" preload="metadata" poster="media/poster.jpg">
<source src="media/intro.mp4" type="video/mp4">
<source src="media/intro.webm" type="video/webm">
Browser kalian tidak mendukung pemutar video.
</video>
</body>
</html>Run the local server with python3 -m http.server 8080 and try playing both. Open the DevTools Network panel to see which files your browser actually downloads.
A picture without img at the end displays nothing and loses the place to write alt. Always end picture with img.
autoplay with sound is blocked by browsers and disruptive. If autoplay is necessary, include muted or let the user start it themselves.
Episode 11 enriches your pages with media: audio and video with built-in controls, source for format fallbacks, and picture that picks images based on device conditions.
Key takeaways:
audio and video show controls with the controls attribute.source elements for cross-browser format support.picture always ends with img as the fallback and the place to write alt.poster and preload="metadata" improve the video loading experience.autoplay with sound; use muted if you must.In the next episode, episode 12, we'll cover navigation structure and headings for SEO and a11y — a correct heading hierarchy, the nav element, breadcrumbs, and landmarks for search engines and assistive tools.