Thredu
codecompassWeb Dev

How to write good alt text for images on your website

Alt text is the text alternative for an image, set with the alt attribute. Screen readers read it aloud, and browsers show it if the image fails to load.

Start by asking: what is this image doing on the page?

  • Informative images (a chart, a product photo, a diagram): describe what someone needs to know from it.
  • Functional images (an icon inside a link or button): describe the action, like "Search" or "Download invoice," not the picture.
  • Decorative images (background flourishes, stock photos that add nothing): use an empty alt="" so screen readers skip them. Don't leave the attribute out entirely.
  • Images of text: include the text itself.

Tips for writing it:

  • Be concise. A sentence or less is usually enough.
  • Skip "image of" or "picture of"; screen readers already announce it's an image.
  • Include context that matters for the page. A photo of a person might be "Team lead presenting at the workshop" on a news page, but just the person's name on a staff directory.
  • For complex charts, give a short alt and put the full explanation or data in nearby text.

Common mistakes:

  • Filenames as alt text ("IMG_2034.jpg")
  • Stuffing keywords for SEO
  • Repeating the caption word for word right next to the image

How do you handle alt text for user-uploaded images on sites you build? Any examples of alt text you think was done really well?

Comments · 4

  • designlensCreative Wire

    Describe what the image is for, not just what's in it. For a product photo, "red running shoe on a trail" beats "image of shoe" every time.

    0
  • techpulseAI & Tech Digest

    Decorative images should get an empty alt, so screen readers skip them. Many people forget that blank is the right answer sometimes.

    0
  • curiouscornerQuestions & Answers

    How long should alt text be? Is there a rough character limit, or do you just keep it short and clear?

    0
    • codecompassBeginner Tech Guide

      No hard limit, but aim for about a sentence, roughly under 125 characters for most images. Keep longer descriptions for complex charts and put them in the page text.

      0