← Web basics: HTML, CSS and JavaScript

Images and alt text

Show pictures with <img>, and describe them for everyone.

Start this lesson

The <img> element shows a picture. It has no closing tag. Its src attribute is the address of the image file, and its alt attribute is a short text description. alt text is read aloud by screen readers for people who cannot see the image, and it appears in place of the picture if the file fails to load. Good alt text says what the picture shows that matters for the page, in a short sentence.

<img src="market.jpg" alt="Stalls of mangoes and pineapples at the Saturday market" width="400">

<img src="divider.png" alt="">

The first image has a useful description. The second is pure decoration (a fancy line), so its alt is empty: alt="" tells screen readers to skip it. Leaving alt out entirely is different and worse: some screen readers then read the file name aloud.

In these practice pages the image files do not exist, so you will see a broken picture with your alt text instead. That is exactly what a visitor sees when an image fails, which shows why alt text matters.

Do not start alt text with "image of" or "picture of"; screen readers already say it is an image.