FSM Full Stack Masterclass
Platform under construction
HTML course badge

HTML Elements

Intermediate

HTML Media Elements

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 elements add images, responsive sources, video and audio.

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.

Element group: img, picture, video, audio. Images and rich media with accessibility and performance concerns.

What belongs here

Learn the tags by job, not by memorizing a random list.

img

Embeds an image and requires thoughtful alt text.

picture, source

Lets the browser choose different image sources.

video

Embeds video, usually with controls and captions.

audio

Embeds audio, usually with controls and transcripts.

Syntax in context

Media markup should describe and optimize the asset.

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

The difference is usually meaning, not only syntax.

Good

<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>

Weak

<img src="image1.jpg">
<video src="intro.mp4" autoplay></video>

Rules that matter

Use these rules before publishing real HTML.

Alt text matters

Describe meaningful images. Use empty alt only for decorative images.

Reserve dimensions

Width and height help prevent layout shift.

Use loading carefully

Lazy loading is useful for below-the-fold images.

Controls for media

Users should be able to pause, replay and control audio or video.

Production thinking

HTML is also for accessibility, SEO, security and maintenance.

Why does this matter?

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.

Accessibility

Images need text alternatives when they communicate meaning. Video often needs captions or transcripts.

Production note

Media is often the heaviest part of a page. Optimize formats, sizes and loading behavior before shipping.

Live code lab

Change the code and run the example.

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

Try this now.

  • Change the image src to "cat.jpg".
  • Change the alt text so it describes the image you expected to load.
  • Run the preview and notice what happens when the browser cannot find the file.

Practice assignment

Do this before moving to the next lesson.

  1. Change one meaningful part of the HTML, not only the visible text.
  2. Run the preview and check whether the result still makes semantic sense.
  3. Explain why the element or attribute you changed belongs in this exact place.

Try it yourself

Build an accessible media card

Live preview

Self-check

Before you continue, prove that you own this lesson.

Intermediate

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.

  1. Can you explain what problem this lesson solves in a real website?
  2. Can you identify the most important tag or attribute from this lesson?
  3. Can you name one accessibility mistake this lesson helps prevent?
  4. Can you write one good example and one weak example without copying the page?
  5. Can you explain when you would use this in production and when you would avoid it?