If an image contains words, put those words in the alt text, exactly as they appear. Better still, avoid putting words in images at all.
Both halves of that come from the sources, and they pull in slightly different directions. Here's how they fit together.
The first choice: real text
Section508.gov, a US government site, says not to include text as part of an image when possible. Type the text on the page and adjust the formatting until it looks right.1
WebAIM, an accessibility group, gives reasons. It says "true text should be used whenever possible", and that true text "uses less bandwidth, supports translation, is searchable, and is easier to maintain and customize". It also scales smoothly when someone zooms in, while images can become pixelated.2
MDN, the web documentation run by Mozilla, is stronger still: "you should never include text content inside an image — screen readers can't access it". It adds that you can't select the text or copy and paste it.3
When the words have to stay in the image
Sometimes you can't avoid it. A poster you scanned, a menu photographed on a wall, or a flyer for an event might only exist as a picture.
Then Section508.gov's rule applies. If an image contains text, include it in the alt text word for word. Its helpful example is a card with its heading and event details copied out in full. Its unhelpful example is a vague label, "Event details with registration button".1
So yes, repeat the words. They'd otherwise be locked inside the picture.
If the image is long, with a lot of text, you're better off putting the words in the page itself, in a paragraph or a list. Then the image can have a short alt text or, if the page now says everything, an empty one. The page on blank alt text covers that last choice.
Screenshots
A screenshot is a picture of a screen, so it often contains words, buttons and menus. The same logic applies.
Start with why the screenshot is there. Section508.gov wants what's relevant, not just a description of the look.1 If you're showing where to find a setting, say which setting and where. Don't list every menu item.
For example: "Settings page with the Image description box filled in." That covers the point. If the exact wording of a button matters, say it in the surrounding steps, in real text. Then the instructions work for everyone, even if the picture doesn't load.
Section508.gov also says alt text shouldn't contain extra or unnecessary information, or repeat what's already in the text.1
Logos with words in them
A logo is the one place where text in an image is expected. WebAIM notes that logos are exempt from the rule against images of text.2 Section508.gov says to include the logo's text word for word in the alt.1 There's more in the page on logo wording.
A quick test
Look at the image, then at your alt text. Could someone who only has the alt text do whatever the image lets a sighted visitor do? Could they read the same offer, the same dates, the same instructions?
If not, add the missing words. If the list is long, move the words into the page and shorten the alt.
Sources used
- Authoring Meaningful Alternative Text, Section508.gov (US General Services Administration)
- WebAIM: Accessible Images, WebAIM
- HTML accessibility, MDN Web Docs (Mozilla)
