Elements with role="img" must have alternative text
When you give an element `role="img"`, for example a `<div>` with a background image or an emoji, it needs a text alternative through `aria-label` or `aria-labelledby`.
| Rule ID | role-img-alt |
|---|---|
| Impact | Serious |
| Success criterion | 1.1.1 Non-text Content · A |
| Standards | WCAG 2.0 · WCAG 2.1 · WCAG 2.2 · Section 508 · EN 301 549 |
| Fixed with a text: from the page or written by AI |
Example
<p>
Rating:
<span role="img" class="stars stars-4"></span>
</p>A screen reader announces “Rating: image”, without the score.
<p>
Rating:
<span role="img" class="stars stars-4" aria-label="4 out of 5 stars"></span>
</p>A screen reader announces “Rating: 4 out of 5 stars, image”.
Why it matters
Adding role="img" tells assistive technology to treat an element as a single picture and to ignore its inner content. That is useful for star ratings, emoji, icon fonts and CSS background images. But the role also promises a text alternative. Without one, screen reader users hear only “image” and miss the information: a 4-star rating, a warning icon, a flag showing the shipping country.
Because the role hides the element's children, any text inside it is no longer read either. The only way to convey meaning is the accessible name you provide.
How to fix it
Add a name that says what the image means, not how it looks.
Use aria-label for short alternatives:
<span role="img" aria-label="Warning">⚠️</span>
Use aria-labelledby when the description is already visible on the page:
<div role="img" class="floor-plan" aria-labelledby="plan-caption"></div>
<p id="plan-caption">Ground floor plan: lounge, kitchen and garden room</p>
Group of shapes forming one picture. Wrap them in one element with role="img" and a single name, instead of naming every part.
Decorative element. If the element only decorates, do not use role="img" at all. Hide it instead:
<span class="divider-flourish" aria-hidden="true"></span>
Prefer real images. When the picture is content, a plain <img> with alt is usually simpler and better supported than a CSS background with role="img". CSS images also disappear in Windows high contrast mode, so content images belong in the HTML.
Checklist
- Add aria-label or aria-labelledby to every role="img" element.
- Describe the meaning, such as the rating or the warning.
- Remove role="img" from decorative elements and use aria-hidden.
- Prefer an img element with alt where you can.
How the check works
The check looks at HTML elements with role="img" or role="image", except <img>, <area>, <input> and <object>, which have their own checks. It passes when the element has an aria-label, an aria-labelledby that points to text, or a non-empty title. Otherwise it is reported. The quality of the text needs a manual review.
Resources
- Understanding 1.1.1 Non-text Content W3C
- W3C ACT rule 23a2a8 W3C ACT
- Images tutorial W3C WAI
- Providing accessible names and descriptions W3C WAI
Updated October 27, 2026