Skip to content
tezvyn:

Image Alt Text: What Screen Readers Say About Pictures

Source: w3.orgEasyHow cards are made

Image Alt Text: What Screen Readers Say About Pictures

Alt text tells screen readers what to say when an image can't be seen. For a photo, describe the scene. For a button, describe its action ("Submit form"). For pure decoration, use an empty alt="" to tell screen readers to skip it.

Why it exists

Not everyone experiences the web visually. Images can create major barriers for people using screen readers, users on slow networks who disable images, or even search engines trying to index content. Image alt text provides a machine-readable, textual equivalent to ensure no one misses out on critical information or functionality.

The mental model

Think of alt text as a script for an assistant describing a webpage over the phone. You wouldn't just say "there's a picture here." You'd explain what the picture shows (if it's important) or what the picture does (if it's a button). If the picture is just a decorative swirl, you'd tell your assistant to ignore it and move on.

How it works

The alt attribute on an HTML <img> tag provides the text alternative. The content of that attribute depends entirely on the image's purpose. There are three primary categories: informative, functional, and decorative. For an informative image like a news photo, the alt text should briefly describe the essential information. For a functional image like an icon used as a button, the alt text must describe the action. For a purely decorative image, the attribute should be present but empty (alt=""), which signals to screen readers to skip it. Omitting the alt attribute entirely is an error that may cause a screen reader to read the image's filename aloud, creating noise and confusion.

When to use it

An alt attribute should be present on every <img> tag. Use descriptive text for informative images like photos, illustrations, and simple charts. Use action-oriented text for images used as links or buttons (e.g., "View your shopping cart"). Use an empty alt attribute (alt="") for any image that does not convey information and serves only as visual decoration.

When not to use it

You should never completely omit the alt attribute from an <img> tag. The only time the text content should be empty is for purely decorative images. For complex images like detailed graphs or charts, the alt text should provide a brief summary and ideally point to a longer, more detailed description available elsewhere on the page.

One canonical example

An e-commerce site uses a magnifying glass icon inside a button to trigger a search. A bad implementation is alt="magnifying glass icon". This describes the visual but not the function. A good implementation is alt="Search products". This tells the user exactly what the button does. If the site has a decorative swoosh graphic next to the page title for branding, its tag should be <img src="swoosh.png" alt="">. This ensures a screen reader simply ignores it.

Interview question

For an image of a magnifying glass icon that triggers a search and a purely decorative swoosh graphic, what are the correct alt text implementations?

  • a.Magnifying glass: alt="Search"; Swoosh: alt="".Correct
  • b.Magnifying glass: alt="magnifying glass icon"; Swoosh: alt="swoosh graphic".
  • c.Magnifying glass: alt="Search"; Swoosh: omit the alt attribute.
  • d.Magnifying glass: alt=""; Swoosh: alt="decorative element".
Why?

For functional images like a search button, alt text must describe the action, not just the visual appearance. For purely decorative images, the alt attribute should be present but empty (alt="") to instruct screen readers to skip them. Option B incorrectly describes both visually, failing to convey function and adding unnecessary information for decorative elements.

Just read this? Test yourself on what you have been reading.

Read the original → w3.org

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on accessibility — each one lists the topics its interview covers.

See open roles