Skip to content

Tutorial

How to write good alt text

1 min read

In short

An image needs alt text exactly when it carries information that would otherwise be lost. If the image is a link or a button, the alt text describes the function („Basket“), not the motif („shopping cart icon“). Pure decoration gets alt="" (empty but present) so assistive technology skips it.

At a glance

  1. Determine the role of the image

    Ask: information, control, or decoration? Everything else follows from that.

  2. Information: describe what is meant

    Write what the viewer is supposed to take from it, not what kind of image it is.

  3. Control: name the function

    For images inside links or buttons the alt text describes the destination or action.

  4. Decoration: set an empty alt

    Use alt="" rather than omitting the attribute, otherwise the filename is read out.

Any testing tool finds a missing alt attribute in seconds. Whether the text inside it is any good takes a judgment about context: the same image needs different alt text in a product catalogue than in a manual. So good alt text starts with a question rather than with writing.

The one question: what role does the image play?

  • It carries information stated nowhere else: describe the information.
  • It is a link or a button: describe the function, not the motif.
  • It merely repeats adjacent text or is purely decorative: empty alt attribute.
  • It is a complex image (chart, map, floor plan): a short core message in alt, the detail as text on the page.

Common mistakes

Before: four common casesHTML
<!-- 1. Kein alt: der Screenreader liest den Dateinamen vor -->
<img src="produkt-4711-final-v2.jpg">

<!-- 2. Alt beschreibt das Bild statt seiner Funktion -->
<a href="/warenkorb">
  <img src="cart.svg" alt="Einkaufswagen-Symbol">
</a>

<!-- 3. Fuellwort statt Information -->
<img src="umsatz-2026.png" alt="Diagramm">

<!-- 4. Dekoration mit Alt-Text: laermt ohne Nutzen -->
<img src="trenner-welle.svg" alt="dekorative Welle">

With the attribute missing entirely, screen readers usually announce the filename. With „shopping cart icon“ on an icon link, you learn what you are looking at but not where the link goes. And alt text on pure decoration is noise that adds nothing.

What it looks like done right

After: decided by roleHTML
<!-- 1. Inhaltsbild: sagt, was man auf dem Bild erkennen soll -->
<img src="produkt-4711-final-v2.jpg"
     alt="Blaue Laufschuhe, Seitenansicht, mit weisser Sohle">

<!-- 2. Bild als Link/Button: der Alt-Text ist die FUNKTION -->
<a href="/warenkorb">
  <img src="cart.svg" alt="Warenkorb">
</a>

<!-- 3. Datenbild: die Aussage, nicht die Bildgattung -->
<img src="umsatz-2026.png"
     alt="Umsatz 2026: Anstieg von 1,2 auf 1,9 Millionen Euro">
<!-- Die vollstaendigen Zahlen stehen zusaetzlich als Tabelle im Text -->

<!-- 4. Dekoration: leeres alt, damit sie uebersprungen wird -->
<img src="trenner-welle.svg" alt="">

An image with a visible caption

figure and figcaptionHTML
<!-- Bild mit sichtbarer Bildunterschrift: alt und caption
     duerfen sich nicht wiederholen, sonst hoert man alles zweimal -->
<figure>
  <img src="grundriss.png"
       alt="Grundriss: Eingang links, Kasse rechts neben dem Ausgang">
  <figcaption>Der barrierefreie Zugang liegt an der Ostseite.</figcaption>
</figure>

Caption and alt text do different jobs: the caption places the image in context, the alt text describes it. If both are identical you hear the same sentence twice in a row.

Length and testing

  1. One line is usually enough. Anything longer belongs next to the image as text, not in the attribute.
  2. Read the alt text out loud without looking at the image: do you understand what it is about?
  3. Check the order and the sound in the browser with images off, or with a screen reader.

Frequently asked questions

When is an empty alt attribute correct?
When the image carries no information of its own: dividers, ornaments, background patterns, or an icon right next to identical text. alt="" tells assistive technology explicitly that there is nothing to take here. Omitting the attribute is not the same thing.
How long may alt text be?
There is no fixed limit, but many screen readers read it in one go with no way to pause. One or two lines is practical. If more is needed, write the full description as visible text and keep the alt text short.
What about images that contain text?
The text in the image belongs in the alt text, otherwise it is lost. Better still is real text styled with CSS instead of an image: it scales, it is searchable, and it also satisfies 1.4.5 (Images of Text).

Request a free scan

Tell us your domain - we run a free initial scan and show you the most important barriers.