Websites & Hosting

Writing Useful Alt Text

How to decide what alt text each image needs, with examples for photos, icons, links, charts and decoration.

Key takeaways

  • Alt text should convey the image's purpose in its context, not list everything visible in it.
  • Decorative images need an empty alt="" attribute, which is different from leaving the attribute out.
  • When an image is a link or button, describe where it goes or what it does.
  • Charts and diagrams need a short alternative plus the full information in nearby text or a table.
  • Check alt text by reading the page with images replaced by your words and asking whether anything is lost.

Useful alt text gives someone who can't see an image the same information or function the image gives everyone else. So the right words depend on why the picture is there. A photo on a product page needs a description of what matters to a buyer, an icon used as a button needs the name of the action, and a purely decorative flourish needs an empty value so screen readers skip it.

This guide gives you a quick way to decide, plus worked examples for the cases that cause the most doubt.

What alt text is

The alt attribute on an HTML img element holds the text alternative:

<img src="/images/ferry.jpg" alt="Passengers boarding a small ferry at dusk">

Screen readers speak it, braille displays render it, and browsers may show it when an image fails to load, which helps people on weak connections. Search engines also use it as one clue about the image. It is not a tooltip and not a place for keyword lists.

If you leave alt out entirely, many screen readers fall back to announcing the file name, so a listener might hear a long string of numbers. If you write alt="", you're saying "there's nothing here you need," and the image is skipped.

Ask why the image is there

Work through the purpose before writing a word.

What should this image's alt be?
Is the image a link or button on its own? YES Name the destination or action, such as 'Search'. 1 NO Is it purely decorative or already explained in text? YES Use an empty alt so it is skipped. 2 NO Is it a picture of text? YES Repeat the words, or better, use real text. 3 NO Is it a chart or complex diagram? YES Give a short summary and put full data nearby. 4 NO Informative image Describe what matters here, briefly. Is the image a link or button on its own? 1 IF YES Name the destination or action, such as 'Search'. NO Is it purely decorative or already explained in text? 2 IF YES Use an empty alt so it is skipped. NO Is it a picture of text? 3 IF YES Repeat the words, or better, use real text. NO Is it a chart or complex diagram? 4 IF YES Give a short summary and put full data nearby. NO Informative image Describe what matters here, briefly.

The same photograph can need different text in different places. A picture of a dog catching a disc might be "Border collie leaping to catch a flying disc" in a gallery about dog sports, "Our shop dog, Biscuit" on a staff page, and nothing at all if it sits as background mood beside an article that never refers to it.

Write the informative ones well

Good alt text is specific and short. A sentence or a phrase is usually enough.

  • Lead with the most important thing.
  • Include details that change meaning: action, setting, quantity, expression, visible text.
  • Skip "image of" and "picture of," since the screen reader already says it's an image. Naming the medium is fine when it matters, such as "oil painting" or "screenshot."
  • Match the tone of the page.
  • End with a period if it reads as a sentence, which gives a natural pause.
  • Don't repeat the caption word for word.
Context Weak Better
Product page "shoe" "Brown leather ankle boot with side zip and low block heel"
News story "photo" "Volunteers stacking sandbags along a flooded main street"
How-to step "screenshot" "Network settings with the DNS field highlighted"
Team page "IMG_2047" "Four staff members smiling in front of the workshop"

When writing about people, describe what's relevant and visible. Don't guess at identity, ethnicity, health or feelings you can't know. Use names when they're established by the page.

If an image is the only content of a link, its alt text becomes the link's name. A logo that goes to the homepage might be alt="Example Bakery home". A magnifying glass in a search button should be named "Search," not "magnifying glass."

If an icon sits next to visible text saying the same thing, hide the icon from assistive technology so the word isn't announced twice. With an img, use alt="". With an inline SVG, add aria-hidden="true". For an SVG that carries meaning by itself, give it role="img" and an accessible name through a title element or aria-label.

Linked thumbnails in a grid should make each destination distinguishable. Twelve links all announced as "thumbnail" are useless.

Deal with charts, diagrams and maps

A complex graphic can't fit into one phrase. Split the job: a short alt that identifies the graphic and its main message, and a fuller version in the page itself.

Parts of a good chart alternative
Bar chart 1 Orders by month 2 Rising, peak in June 3 Table below 4 Type Tells the listener what kind of graphic it is. 1 Subject Says what is being measured. 2 Main message States the takeaway a sighted reader sees. 3 Full data Points to the numbers in real text. 4 Bar chart 1 Orders by month 2 Rising, peak in June 3 Table below 4 Type Tells the listener what kind of graphic it is. 1 Subject Says what is being measured. 2 Main message States the takeaway a sighted reader sees. 3 Full data Points to the numbers in real text. 4

An example with made-up figures.

A data table is often the best full version, because screen reader users can move cell by cell. For flowcharts, write the steps as a numbered list. For maps that help someone find you, give the address and directions in text.

Infographics with many words are a special problem. If the content matters, publish it as HTML and treat the graphic as a supplement.

Pictures of text

Text baked into an image can't be resized cleanly, restyled, translated or searched. Use real text with CSS when you can. When you can't, such as for a scanned notice or a logo, the alt should carry the same words. A long scanned document needs a text version, and a PDF to images conversion goes the wrong direction for accessibility, so keep the original text where you have it.

Worked examples for tricky cases

A photo beside text that describes it. A recipe says, "Fold the dough into thirds," and shows a photo of that fold. If the photo shows something the words don't, such as which edge goes over first, describe that detail. If it adds nothing, an empty alt is fine.

An author portrait next to the author's name. The name is already there, so alt="" avoids hearing it twice. On a profile page where appearance is the point, describe it briefly.

A product shot in a category grid. If the product name is part of the same link, the image can be empty so the link is announced once. If the image is the only link content, its alt must name the product and ideally what separates it from its neighbors.

A screenshot in instructions. Describe what the reader should notice and do: "Settings page with Automatic updates switched on." Put error messages and values in the body text too, so people can copy them.

A humorous image or meme. Include the visible words and enough of the scene for the joke to work.

A functional image such as a star rating. Give the value: "Rated 4 out of 5." Five separate star images each announced would be noise, so label the group once and hide the pieces.

A CAPTCHA or verification image. Describing the answer defeats its purpose, so the alt should state what it is and the page should offer a non-visual alternative.

Who writes it and how to review it

The person who chose the picture usually knows why it's there, which makes them the best author. Give writers a one-page guide with the purpose question, a few examples from your own site and your preference on tone.

During editing, read the page aloud, replacing each image with its alt text. The passage should still make sense, without odd repetitions or sudden gaps. Reviewers can ask three things: would a reader miss anything, would they hear anything twice, and could these words be pasted under any other image? If the last answer is yes, the description is too generic.

For large old libraries, don't try to fix everything at once. Start with templates, navigation icons and your most visited pages. A single repair to a shared header can improve every page, while an old gallery nobody visits can wait. Record decisions so the next editor handles similar images the same way.

When images change, revisit the text. A swapped banner that keeps the old description is worse than a plain one, because it confidently says something false.

Where alt text goes wrong

Common mistakes:

  1. Stuffing keywords, which sounds absurd read aloud and can hurt rather than help search.
  2. Writing paragraphs for simple photos.
  3. Using the file name or "image."
  4. Leaving decorative dividers and spacers described.
  5. Putting essential information only in alt text, where sighted users never see it.
  6. Publishing automated captions unreviewed. AI tools can draft descriptions, but they miss context and sometimes invent details, as checking AI output cautions.

Social platforms and email tools usually offer their own alt text field. Use it, and in newsletters make sure the message still works with images blocked, a point raised in why HTML email is so hard.

Put it into your publishing workflow

Make alt text a required decision when images are uploaded, with "decorative" as an explicit choice instead of a blank field. Remember that a value stored in a media library may not suit every page where the image is reused, so check it in context.

To audit an existing page, run an automated checker to find missing attributes, then turn images off or read through with a screen reader and judge quality yourself. Prioritize images that act as links or buttons, then those that carry information needed to complete a task.

Alt text is one part of a larger effort described in web accessibility explained. While you're handling images, it's also a good time to shrink them, following choosing and preparing images for the web, and to check that any photos from your phone don't carry location data, as described in photo metadata.

Common questions

How long should alt text be?

Long enough to serve the purpose. Many good examples are under a couple of sentences. If you need more, the extra belongs in visible text.

Should every image on a page have the alt attribute?

Yes. Each img should have it, either with a description or deliberately empty.

Do background images need alt text?

CSS background images have no alt attribute, so don't use them for anything that carries information. If one does, provide the content as real text.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Websites & Hosting →

Latest news on this topic