accessibility · media
Alt text
also called alternative text (wcag), text alternative (wcag), alt attribute (html), image description
The text alternative that stands in for an image, written to serve the same purpose in the same context rather than to describe every detail.
Alt text is not a description of an image. It is a replacement for one. The test to write against is simple: take the picture away, put your sentence in the hole it left, and read the page. If it still does the same job, the alt text is right.
That test settles most of the arguments, because it makes the answer depend on
context rather than on the file. The same photograph of a coffee grinder is “Baratza
Encore, matte black” in a shop listing, “the grind size dial set to 18” in a tutorial
about grind size, and nothing at all in a hero banner where the words beside it
already say everything. Purely decorative images take an empty alt="", which is not
the same as leaving the attribute off: an empty alt removes the image from the
accessibility tree, and a missing alt leaves screen readers announcing a filename.
The usual rules follow from the test. Do not open with “image of” or “photo of”, since the reader is already told it is an image. Do not repeat the caption or the sentence next to it, which produces the same words twice. If the image is a link or a button, the alt text names the destination or the action, not the picture, because that is what the control does. If the image is a chart or a diagram carrying data, the alternative is longer than an attribute holds, so put the content in the page and point at it.
Alt text is also the fallback the browser reaches for when an image does not arrive: blocked, mistyped, still loading on a bad connection. That is why the alt is worth sizing for. An image box that keeps its dimensions and shows its text alternative degrades into something readable instead of into a broken icon.
Which word?
| If you want | say |
|---|---|
| writing what an image says when it cannot be seen | alt text |
| asking what a control is actually called out loud | accessible name |
| text for screen readers that never shows on screen | visually hidden |
| the picture adds nothing a reader would miss | decorative image |
| a chart needs to work for readers who cannot see it | chart description |
| arguing a headline should be text, not a picture of text | images of text |
| the image is data and one line will not do | long description |
Related
See also: Image
Implementations
Specimens illustrate the concept; for production use, start here.
| fluent | Rich media and alternatives |