CodePark/ questions / Images & media
START PRACTICINGPRACTICE
Frontend question · Accessibility › Images & media

How do you decide what alt text to write for an image? Walk through the main cases.

Ask: what job does this image do on this page? Then write alt text that does the same job in words. The same photo can need different alt text on different pages.

The main cases:

  • Informative image: it adds information, like a product photo or a diagram. Describe what matters in a short phrase: "Red running shoe, side view". Don't start with "Image of", because the screen reader already says "image".
  • Functional image: it is the only content of a link or button, like a logo that links home or a search icon. Describe the action or destination: "Home", "Search". Don't describe the picture ("magnifying glass").
  • Decorative image: it adds nothing, like a background swirl. Use alt="", so screen readers skip it. Never leave alt out entirely, because some screen readers then read the file name.
  • Image of text: the alt text is the text itself. Better still, use real text.
  • Complex image: a chart or a map. Give a short alt like "Sales by month, 2025", and put the full data in a table or text next to it.

Also, if the text right next to the image already says the same thing, use alt="" to avoid hearing it twice.

  • Alt text depends on the job the image does on that page.
  • Informative images get a short description of what matters.
  • Images inside links or buttons describe the action or destination.
  • Decorative images get alt="", and the attribute is never left out.
  • Complex images get a short alt plus a full text or table version nearby.