Web development

Write useful image alternative text

Choose alternative text according to the image’s role. Describe meaningful information, and use an empty alt attribute for a decorative image that adds no content to the surrounding text.

Worked example

HTML example · save as example.html and open in a browser

<figure>
  <img src="/images/example-chart.png" alt="Requests rise from 20 in May to 35 in June." width="640" height="360">
  <figcaption>Illustrative monthly request counts.</figcaption>
</figure>
<img src="/images/decorative-divider.png" alt="" width="640" height="20">

How it works

The informative image’s alternative communicates the relevant trend rather than merely saying chart. The decorative divider has an empty alternative so it need not be announced as content. Dimensions also reserve layout space while assets load.

Limits and mistakes

The sample asset paths must be replaced with real images. Do not put essential complex chart data only in a long alt string; provide the underlying values in nearby text or a table. Linked images need text that explains the link’s purpose.

Check the result

Disable images or inspect the accessibility tree and read the remaining content. Confirm the page still communicates the chart’s key information without announcing the decorative divider.

Sources

Reference documentation for the behavior used in this guide: