Skip to main content
Albero Academy

Images

Add images with the img element and alt text.

Text & Links8 min

The <img> element embeds an image. It's a void element with two key attributes: src (where the image is) and alt (a text description).

The img element

src and alt
<img src="cat.jpg" alt="A ginger cat sleeping on a sofa"
width="400" height="300" loading="lazy" />

Why alt text matters

Modern images

The <picture> element and srcset serve different image sizes/formats for different screens — the responsive-images pattern for performance.

Key takeaways

  1. 01<img> embeds an image; src is the source, alt is the text description.
  2. 02Always provide meaningful alt text (empty alt="" for decorative images).
  3. 03Set width/height to prevent layout shift; loading="lazy" defers off-screen images.
  4. 04<picture>/srcset serve responsive images for different screens.

Finished this chapter?

Mark it complete to track your progress through HTML.