Skip to main content

Media for HTMLs

HTML media elements embed images, audio, video and other content into a page. The img element needs an alt attribute and dimensions, picture and srcset serve different files to different screens, audio and video provide native players, and iframe embeds external pages. Each choice affects accessibility and load speed.

Stage: Media and Data · Part of the HTML roadmap · Last reviewed 19 November 2026

What to learn in Media

Media interview questions

What is alt text and when should it be empty?

Alt text is a text alternative for an image, read by screen readers and shown if the image fails. Describe the purpose of informative images. For purely decorative images use alt="" so assistive technology skips them instead of announcing a filename.

Why set width and height on img elements?

Browsers use the dimensions to reserve space before the image loads, which prevents the layout from jumping and improves Cumulative Layout Shift. CSS can still resize the image responsively while the aspect ratio is kept from those attributes.

Where Media fits in the HTML roadmap

Media belongs to the Media and Data stage (beginner level), which takes about 8 hours. Beyond text.

Back to the full HTML roadmap