Accessibility・First steps

Writing alt text that gets across

alt is "the stand-in for when an image can't be seen." Learn what to write, and how much, through good and bad examples—including alt="" for decorative images.

You learned in the HTML course that the alt of <img> is “the place to write the description of an image.” In this lesson we go one step further and learn what to write, and how, so it actually gets across. For someone using a screen reader, someone whose image failed to load, and search engines, alt is the stand-in for the image itself.

HTMLLet's show an imageThe basics of writing alt (the HTML side) are in this lesson

Good alt, bad alt

Let’s compare using a photo on Shima’s page.

<img src="shima.png" alt="Photo of Shima" />
altVerdictReason
alt="Image"You can’t tell what the image is at all
alt="shima.png"A filename isn’t a description
alt="Photo of Shima"You at least get a rough idea
alt="A fluffy white bird, Shima, perched on a branch"You can picture the scene even without seeing it

The trick is to write it as if you were describing the photo over the phone. One or two sentences is plenty.

The same image, different alt depending on context

There’s no single “correct sentence” for alt. You write the role the image is playing in that particular scene. Even for the same photo of Shima—

  • On a self-introduction page, as a face photoalt="A fluffy white bird, Shima"
  • In a how-to article on preeningalt="Shima grooming feathers with its beak"

That’s because on the self-introduction page the image’s job is to show what Shima looks like, while in the how-to article its job is to show what Shima is doing. When you ask “what is this image responsible for conveying here?”, what to write falls into place naturally.

For graphs and diagrams, write the “conclusion” in alt

For information-packed images like graphs, diagrams, and screenshots, don’t describe the look—write the conclusion you want people to take away.

<img src="graph.png" alt="Shima's snack survey. Sunflower seeds are #1, making up half of the total" />

With alt="Bar chart", only people who can see the image get the information in the graph. You don’t have to write out every last number. Write the reason you included that graph (the thing you most want to convey) in one or two sentences, and if the detailed figures matter, show them in the body text or a table too.

Decorative images get alt=""

There are also meaningless decorative images, like background patterns or divider lines. Writing “pattern image” or the like there is just noise for someone listening. Decorations get alt="" (empty).

<img src="border-flower.png" alt="" />

alt="" is a deliberate signal that says “it’s fine to skip this image.” That’s different in meaning from forgetting to write alt at all, so even for decorations, always write alt="".

Clicking the logo takes you back to the top—for such a link image, the alt isn’t the look but what happens when you press it.

<a href="/">
  <img src="logo.png" alt="Back to the top page" />
</a>

Someone listening hears “link, back to the top page” and can press it with confidence. With alt="Logo", they can’t tell where pressing it leads.

Summary of this lesson

  1. alt is the image’s stand-in. Test it by “does the story still make sense with the image removed?”
  2. Decorative images get alt="". Never leave an image without alt
  3. For link images, write the destination or action, not the look

FAQ

How long should alt text be?
One or two sentences is the guide. For images that need more explanation than that (graphs, diagrams, and so on), write just the key point in alt and put the detailed explanation in the body text.
Should I write "an image of ~" or "a photo of ~" in alt?
You don't need "image." The screen reader already announces "image" when it hits the img tag, so it would be redundant. Add "photo" or "illustration" only when that distinction actually matters.
What if I can't decide whether an image is decorative or meaningful?
Judge by whether removing the image would reduce the information that gets across. If it would, write a description; if it wouldn't, treat it as decorative with alt="".