Skip to content
Tutorials Center
My learning

Topics

Lesson 11 of 38 ยท Semantic HTML and ARIA

Images and Text Alternatives

Learn how to write alt text for informative, decorative, functional and complex images, and how to handle icons, SVG, charts and background images accessibly.

An image conveys information to people who can see it. Someone who cannot see it needs that information in another form, which is the job of a text alternative. WCAG criterion 1.1.1 (Non-text Content, Level A) is the most basic rule in the standard, and also one of the most often failed.

The art of alt text is deciding what information the image carries in its context. The same photo might need a long description in a news story and no description at all when it is decoration. This lesson gives you a decision process and examples for each kind of image.

The basics

HTML
<img src="/samples/sunset.svg" alt="Orange sun setting over a calm hill">

An <img> must have an alt attribute. If it is missing, screen readers may read the file name ("IMG_4021.jpg"). If it is present and empty (alt=""), the image is announced as nothing, which is right for decorations.

Pick the right alt

Informative Short description of the content
Decorative Empty alt
Functional Describe the action
Complex Short alt plus long text nearby

Always ask what the image is for in context.

1 / 2

Informative images

Describe the information, not the pixels. Keep it concise (usually under one sentence), and skip "image of" or "picture of", since the role is announced already.

  • Weak: alt="graph"
  • Better: alt="Sales rose from 120 units in January to 310 in June"

Decorative images

Images that add visual flair but no information should have alt="". Examples: a swirl divider, a stock photo that repeats the heading, an icon next to text that says the same thing. Prefer CSS backgrounds for pure decoration, since they are invisible to assistive technology by default.

Functional images

When an image is the only content of a link or button, its alt must describe the action or destination, not the picture.

HTML
<a href="/search"><img src="search.svg" alt="Search"></a>
<button><img src="print.svg" alt="Print this page"></button>

Complex images: charts, diagrams, maps

A short alt cannot hold a whole chart. Provide a brief alt that names the thing, and a fuller description nearby: a text paragraph, a data table or a <details> section. Link the two with aria-describedby or by placing them next to each other.

Alt text in context

The button prints each image's alt so you can compare. The decorative image shows "", which is correct and deliberate.

Icons and SVG

  • Icon with visible text next to it: hide the icon from assistive technology, using aria-hidden="true" on inline SVG or alt="" on an image.
  • Icon alone: give an accessible name. For inline SVG use role="img" and aria-label, or a <title> inside the SVG.
  • Icon fonts: avoid them where you can; screen readers may read private-use characters as nonsense.
Icons with and without text

The first button gets its name from visible text, so its icon is hidden. The second has no text, so the aria-label provides the name.

Text in images, CAPTCHAs and backgrounds

Do not put important text in an image: it cannot be resized or restyled and relies on alt. If you must, repeat the exact text in the alt. For CSS background images that carry meaning, provide the same information in real text. For CAPTCHAs, offer alternatives, since an image puzzle alone locks out blind users, as covered in WCAG 2.2.

A practical decision flow

  1. Is the image purely decorative? Use alt="".
  2. Is it inside a link or button without other text? Describe the destination or action.
  3. Does it show information? Convey the same information, concisely.
  4. Is it complex? Short alt plus a long description.
  5. Does it contain text? Reproduce the text.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What should the alt of a decorative image be?

    An empty alt tells assistive technology to skip it. Omitting alt is a different and worse choice.
  2. 2. A magnifier icon is the only content of a search link. Best alt?

    Functional images describe the action, not their appearance.
  3. 3. How should a complex bar chart be handled?

    Alt is for short text. Provide the details in visible content that everyone can use.
  4. 4. A button shows an icon and the word Schedule. What about the icon?

    The text already provides the name, so the icon would be redundant noise.

Summary

  • Every <img> needs an alt; the right value depends on the image's role in context.
  • Use empty alt for decoration, action text for functional images and short alt plus description for complex ones.
  • Hide icons that sit beside text; name icons that stand alone.
  • Avoid text in images and never rely on a background image for meaning.

Next: Links and Buttons