role-img-altElement with role="img" has no text alternative
An element with role="img", such as a background image, emoji or star rating, needs a text alternative or it is announced as just “image” or skipped. Add an aria-label describing it, or remove role="img" and add aria-hidden="true" if it is purely decorative.
Who it hurts
Blind and low-vision people using screen readers or braille displays.
Star ratings and hero banners drawn with CSS are the usual cases, so ratings and key messages are lost.
How to fix it
Pick your stack. Review every change before you ship it.
Before
<div role="img" class="hero" style="background-image: url(team.jpg)"></div>After
<div role="img" aria-label="Our team outside the Leeds workshop" class="hero" style="background-image: url(team.jpg)"></div>Check it by hand too
Read each one with a screen reader. The label should tell you what the image tells a sighted visitor, such as “Rated 4.5 out of 5”.
Automated checks find a large share of accessibility problems, but not all of them. Passing this check does not on its own make a page compliant.
WCAG reference
- 1.1.1 Non-text Content (Level A). Understanding 1.1.1