Images can be effective way to convey meaning, such as to provide additional information to text content or to assign labels to buttons. Text alternatives are vital for people who can’t see them. When icons are added as images, the best practice is the same as for providing alternative text for images. When other methods are used, such as background images or icon fonts, additional care is needed to ensure that their meanings are available to screen reader users, people with reading difficulties, and those who use Windows High Contrast Mode or who need to apply a user-defined style sheet that changes fonts.
- Provide appropriate text alternatives for images. See Content Creators: Describe the content of images for best practices for writing text alternatives.
- Make sure icon fonts have accessible text alternatives. Reliable ways for providing accessible text alternatives vary depending on how the icon is provided. Preferably, use icon fonts, because icons should still be displayed in Windows High Contrast Mode. Provide a text equivalent for the icon as text in HTML, and use CSS to hide the text equivalent visually while making that text available to screen readers. Use a font-detection script to check whether a user-defined stylesheet is being applied, and if so, dynamically update the CSS to display the text alternative.
When an image is being used for labeling a control (such as a button) or for providing information (such as a logo):
- If it is provided as an image, does it contain a meaningful text alternative?
- If it is provided using an icon font or a CSS background image, is there a text alternative that’s read by a screen reader and is displayed when a user-defined style sheet changes fonts?
- Understanding WCAG SC 1.1.1—Non-text Content (WAI)
- Understanding WCAG SC 1.3.1—Info and Relationships (WAI)
- Understanding WCAG SC 4.1.2—Name, Role, Value (WAI)
- Icon fonts and user-defined stylesheets (Juicy Studio)
- Font detection script example
- Windows High Contrast Mode detection script example (Karl Groves)