Text alternative for images
In a nutshell ...
Provide alternative text for images.Make sure it conveys the same message.
Every image must ...
-
... have a text equivalent that serves the same purpose,
if it conveys information or a functionality. -
... or be silenced,
if it doesn't convey any information,
or if the information it conveys is always available in text.
This is so that ...
- People who use screen readers can perceive information conveyed via images.
- People who use speech input software can trigger buttons and links that include icons.
On this page:
1. Images that convey information
§-
Does the image convey any information?
→ The text alternative should convey the same information as the image. -
It's not about describing what's on the image:
It's about serving the same purpose as the image (conveying the same information).A picture can seek to convey different information in different contexts.
Example
On a page promoting a holiday resort, the purpose of this picture might be to convey that the resort is family friendly.
2. Images that convey functionality
§-
Does the image describe what a button or a link is going to do?
→ The text alternative should describe the action that will be performed. -
It's not about describing what's on the image:
It's about serving the same purpose as the image: indicating what action will be triggered, or where users will be taken to. -
If the button or link also has text label, see Images that are purely decorative or redundant below.
Example
3. Images that are purely decorative or redundant
§-
The image does not convey any information?
Or it conveys information that's already conveyed in text?
→ It should be silenced usingalt=''
, or be a CSSbackground-image
. -
This is so that screen readers and speech-input software ignore it.
Example
If a button's name is already included in text, the icon shouldn't be read out by screen readers.
4. Complex images
§-
Does the communicate complex information (like an infographics, a chart or a diagram)?
→ The same information should be available in text or as a table within the same page.
Common mistakes§
-
An
img
element with noalt
attribute-
If an image doesn't have an
alt
attribute (orrole=
'presentation'
or'none'
), then screen readers will read the filename. -
Always give
img
elements analt
attribute.role=
'presentation'
or'none'
achieve the same outcome. But it's better not to use ARIA attributes when the same outcome can be achieved with just HTML.
Example
With the code below, screen readers would read out the image like this:
"search underscore icon underscore jeo87668 underscore medium underscore 2x.png Search, button".
-
-
Text alternative that does not serve the same purpose as the image
Example 1
The purpose of this magnifying glass icon is to convey a 'Search' functionality. So its alternative text should be 'Search', not 'Magnifying glass'.
Example 2
This alt text describes what's on the image, but doesn't serve the same purpose as the image.
-
Text alternative that includes redundant words like 'image', 'icon', 'button' or 'select this to ...'
-
The type of the element (such as image or button) should not be included in the text alternative.
An element's type is programmatically determined (based on the HTML element's tag name or `role` attribute) and announced by the screen reader.
Example 1
The alt text should not include 'button'.
This would be read out by screen readers as"Play button, button"
.Example 2
This would be read out by screen readers as
"Picture of a happy family, image"
. -
-
Using CSS
background-image
for images that are not purely decorative or redundant-
Do not use a CSS `background-image` for images that convey purpose or information not already available in text.
-
CSS background images are not available to assistive technologies.
-
CSS background images may only used for:
- decorative images
- images that communicate information or functionality that's also described in text.
-
-
Text alternative that is too verbose
-
Try to be succinct (50 characters max).
-
Verbose alternatives make content harder to listen to and understand for screen reader users.
-
More info
§
More guidance
- Official wording in the Web Content Accessibility Guidelines
- Alternative text tutorial by WebAIM explains how to write and set alternative text
- The Image concepts tutorial by the W3C Web Accessibility Initiative
- W3C Alt text decision tree
- Requirements for providing text to act as an alternative for images in the HTML 5.1 specification
- Why CSS `background-image` should not be used to include images that convey important information
Sources and copyright
General guidance and examples
- W3C Web Content Accessibility Guidelines 2.1 Copyright © 2019 W3C ® (MIT, ERCIM, Keio, Beihang). License
- W3C Web Accessibility Tutorials Copyright © 2019 W3C ® (MIT, ERCIM, Keio, Beihang). License
- Government Digital Service WCAG 2.1 Primer licensed under the Open Government Licence v3.0.
- BBC Mobile Accessibility Guidelines licensed under the Open Government Licence v3.0.
- Kin+Carta Accessibility Guidelines licensed under MIT License.
Images
- Search icon: Copyright Rohith M S from the Noun Project, licensed under Creative Commons license
- Pay icon: Copyright Alena Artemova from the Noun Project, licensed under Creative Commons license