Alternative text on images and graphics
Basic principle
All non-text content must have an accessible name. Non-text content includes all font icons, images, SVG elements, non-standard usages of extended ASCII characters, or CSS used to construct interactive element graphics.
Different types of graphics require different implementations; the most common is the img element and the alt attribute. All graphics require some form of alternative text, however.
Note: This requirement does not mean “must have text”; it means “must be explicitly defined.” An empty alt attribute specifically defines the alternative text for an image as empty. This is different from a missing alt attribute, which leaves alternative text undefined. Some icons and images may be decorative.
Decorative graphics may include:
- Graphics used purely ornamentally.
- Supplemental graphics associated with links or buttons where the link or button has a name already defined.
Testing
Tools: Browser inspector, screen reader (recommended)
- For each non-text graphic, inspect the image using the browser inspector.
- In the inspector, determine whether the image has an accessible name.
- If yes, determine whether the accessible name is appropriate.
- If the image is inside a control, identify whether the control already has a name. If the control already has a name, this image may be decorative.
- If the image is decorative, verify that it is hidden from screen readers. For
imgelements, this is done viaalt="". For font icons or extended ASCII, this is done usingaria-hidden="true"on a wrapping element. The wrapping element must not be interactive. Forsvg, this is done usingaria-hidden="true"on thesvgelement or a wrapping parent that is not interactive.
- Verify accessibility of extended ASCII characters if present.
- Extended ASCII characters will not display text in the browser’s accessibility inspector. Most characters have a standard reading value, but not all. If a theme uses ASCII characters in the design, use the article “How Screen Readers read Special Characters” as a reference to know what the screen reader will say, or (recommended) listen to the element with a screen reader.
- If the read text would not be appropriate in context, verify the character is wrapped in a
spanthat either hides the character or provides it with a more appropriatearia-label, depending on context.
WP Accessibility Knowledge Base