When an image is a link or a button, the alt text should say what happens if you use it. Looks come second.
That's the rule for most cases on this page. The details change a little for logos, icons and plain old image buttons.
Pictures that are links
MDN says that for images inside a link or button, "consider describing the triggered action inside the alt attribute value". Its example is writing "next page" instead of "arrow right".1 For a linked picture, MDN also says to "make the alternative text describe the resource the link is pointing to", as if you were using a text link.1
Why does this matter so much? WebAIM, an accessibility group, says that when an image is the only thing inside a link or button, alt text is all a screen reader has. If it's empty or missing, the screen reader might read the file name or the web address instead. WebAIM adds that empty alt text would never be appropriate here.2
Leave out filler. WebAIM says to avoid phrases like "link to" or "click here for" when possible, because screen readers already announce a link as a link.2
Image buttons
Say what the button will do. WebAIM's wording: "The alt text should describe what the button will do when activated." Its examples are words like Search, Submit or Register.2
Better still, skip the picture. Section508.gov says that, when possible, you should render controls and other navigation elements as text.3 Most website builders let you style a plain text button.
Logos
Section508.gov is clear. Logos are never decorative, so they require alt text.3 It also says to include any text in the logo word for word, and to describe any significant symbols or graphics.3
WebAIM takes a lighter approach for a logo that links to the home page. It says that providing your company name will usually do, and that the word "logo" usually isn't an important part of the image's content or function. It also says there's usually no need to say the logo links home, because that's a common convention.2
Where the two sources differ, think about the logo you've got. A plain name in a logo needs just that name. A logo with a tagline in the picture means the tagline's words belong in the alt text too.
Icons
An icon is a small symbol standing in for a word or action: a magnifying glass for search, a cart, a phone handset. WebAIM warns that "Icons almost always require familiarity in order to be useful", and that they can be misread across cultures and languages. It says adjacent text is often helpful.4
So the first question is whether there's already text beside the icon. If the words sit right next to it, inside the same link, WebAIM says the icons should have empty alt so they aren't read out separately.4
If the icon stands alone as the link, its alt text has to carry the whole job. WebAIM's example is a PDF icon next to a link that says to download a form. With the words beside it, the icon's alt could just say "PDF". On its own, the alt should say the full action, such as downloading the form in PDF format.2
A short checklist
- Is the image inside a link or button? Then it needs words, unless text in the same link already does the job.
- Does the alt say where the link goes or what the button does?
- Is it free of filler such as "link to" and "click here", and of "icon" where it adds nothing? WebAIM says "icon" is redundant in its PDF example, but that in a different context it may be important that the user know it is an icon.2
- Would it still make sense if a visitor heard only a list of links, one after another?
The last one matters because WebAIM notes that a screen reader user might move through the links on a page, hearing each one in isolation. Say an icon is the only content of its link. A short label such as "PDF format" repeated across many links gives a screen reader user nothing to tell them apart. The alt text should give the full action, such as downloading the employment application in PDF format.2
For a pure decoration with no function, see the page on empty alt text.
Sources used
- <img>: The Image Embed element, MDN Web Docs (Mozilla)
- WebAIM: Alternative Text, WebAIM
- Authoring Meaningful Alternative Text, Section508.gov (US General Services Administration)
- WebAIM: Accessible Images, WebAIM
