img
Embeds an image and requires thoughtful alt text.
Learn img, picture, video, audio as part of the HTML element system: when to use it, how it fits inside a document and what mistakes to avoid.
Media
Media makes pages visual and useful, but it also creates performance and accessibility responsibility.
Images need useful alt text. Responsive images need the right source strategy. Video and audio need controls and alternatives where the content matters.
img, picture, video, audio. Images and rich media with accessibility and performance concerns. Syntax in context
A media tag is not complete just because it displays. Think about alt text, dimensions, loading, controls and fallback.
<figure> <img src="lesson-dashboard.webp" alt="Code editor showing an HTML lesson dashboard" width="900" height="560" loading="lazy"> <figcaption>HTML lesson dashboard preview.</figcaption> </figure> <video controls> <source src="lesson-intro.webm" type="video/webm"> </video>
Good versus weak
<figure> <img src="lesson-dashboard.webp" alt="Code editor showing an HTML lesson dashboard" width="900" height="560" loading="lazy"> <figcaption>HTML lesson dashboard preview.</figcaption> </figure> <video controls> <source src="lesson-intro.webm" type="video/webm"> </video>
<img src="image1.jpg"> <video src="intro.mp4" autoplay></video>
Rules that matter
Describe meaningful images. Use empty alt only for decorative images.
Width and height help prevent layout shift.
Lazy loading is useful for below-the-fold images.
Users should be able to pause, replay and control audio or video.
Production thinking
Media matters because images and video are often the first thing people notice, but they are also where pages become slow or inaccessible. Good media HTML keeps the visual quality without sacrificing meaning or speed.
Images need text alternatives when they communicate meaning. Video often needs captions or transcripts.
Media is often the heaviest part of a page. Optimize formats, sizes and loading behavior before shipping.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.