How to Write Good Alt Text: A Step-by-Step Method
There's no formula that turns a photo into alt text. What works is a short run of questions, asked in the same order each time. Here's the run.
Step 1: Work out the job
The same picture can need very different alt text depending on how it's used. WebAIM says so outright.1
So begin with the image's content and function.1 Content is what it shows. Function is what it does. An image only has a function if it's linked, has a clickable area in an image map, or sits inside a button.1 If it's none of those, you only have content to deal with. Links and buttons get their own page: labelling logos, icons and linked images.
Step 2: Check the text around it
Does the surrounding text already say what the image says? The HTML standard says the alt value should not repeat information that is already in the prose next to the image.2
WebAIM offers a handy question: if you couldn't use this image, what would you put in its place? If the answer is nothing, WebAIM says an empty alt="" is probably enough.1 The decorative images page, when alt should be empty, goes into this.
Step 3: Say it as you'd say it on the phone
The HTML standard suggests thinking about how you'd read the page to someone over the phone, without mentioning that there's an image. What you'd say in the image's place is a good start.2
Step 4: Keep it short
WebAIM says that typically only a few words are necessary. Rarely, a short sentence or two may be appropriate.1
If you need more than that, the detail belongs in the page itself. The notes on charts and diagrams show how.
Step 5: Cut the filler
MDN says alt text should not describe the presence of the image itself or the file name.3 So "image of" and "photo of" can go. A file name like IMG_final.jpg isn't a description either.3
Don't paste in a caption either. The HTML standard rules out any text that could be taken for the image's caption.2
And don't use alt text as a place to stuff in extra information, or words aimed at search engines. WebAIM calls this a mistake seen too often across the web.1
Step 6: Read it back
MDN describes a simple test. Read the alt text together with the text just before the image, and see if it carries the same meaning as the image.3
MDN's own pair of examples: the alt text "image" next to a penguin photo fails. "A Penguin on a beach." passes.3
Same photo, different jobs
WebAIM works through one portrait of a named astronaut in several settings. Here's the pattern, with the name left out.1
| How the photo is used | What WebAIM suggests |
|---|---|
| In an article, with body text that mentions the person | Short alt text with the job and name1 |
| Next to a caption that already gives the same words | Empty alt text1 |
| As the only content inside a link | Alt text that names the person, because empty alt would never be right here1 |
WebAIM adds that there's no one right answer for every image. The best text depends on the context and what the image is meant to say.1
Reference list
- WebAIM: Alternative Text, WebAIM, Utah State University
- HTML Standard, the img element and alternative text, WHATWG
- <img>: The Image Embed element, MDN Web Docs, Mozilla