role="img" element without a name (role-img-alt)

The role-img-alt rule flags elements with role="img" – a <div>, a <span>, an icon – that have no accessible name. The role tells assistive technology "this is one image", and then there is nothing to announce. The fix is an aria-label or aria-labelledby that says what the image means, or, if it is decoration, removing the role and hiding it.

What the rule means

role="img" turns any element into a single graphic in the accessibility tree. Its content no longer counts: the stars, the emoji or the icon-font glyph inside become part of the picture, and assistive technology reads only the name the author gives it. With no name, a screen reader says "image" or skips it.

axe accepts aria-label, aria-labelledby or a title attribute as the name. Text inside the element does not count, because an image does not take its name from its content. Elements hidden with aria-hidden="true" are not checked.

The rule finds a missing name. It cannot tell whether "Rated 4 out of 5" is actually the rating shown, or whether the element needed role="img" at all – that is a human judgement.

Who is affected

Blind and partially sighted people using a screen reader, who hear "image" – or nothing – where sighted visitors see a rating, a status icon or a hero picture. Braille display users get the same empty cell. The information is lost at exactly the point where the page relies on it, for example a product's star rating or a "sold out" badge drawn as an icon.

Why the check fails

  • Star ratings built from icon fonts or Unicode stars, wrapped in role="img" so screen readers do not read "star star star" – and then never named.
  • CSS background images on a <div role="img"> for hero banners and team photos, where the role was added but no label.
  • Emoji wrapped in <span role="img"> – a pattern from React linting guidance – without the aria-label that goes with it.
  • Icon-font icons (<i class="icon icon-truck" role="img">) in feature lists and status badges.
  • Component libraries that set the role by default and leave the label as an optional prop nobody fills.

How to fix it

  1. Decide whether the image carries information. If it does, give it an aria-label with that information – the rating, the status, what the picture shows.
  2. If a visible caption already says it, point to that text with aria-labelledby instead of repeating it.
  3. If it is decoration, remove role="img" and add aria-hidden="true" so assistive technology ignores it.
<!-- Before: role="img" with no name – the rating is lost -->
<div class="rating" role="img">
  <span aria-hidden="true">★★★★☆</span>
</div>
<!-- Before: a background image made an "image", but unnamed -->
<div class="hero__image" role="img"></div>
<!-- After: the name says what the stars mean -->
<div class="rating" role="img" aria-label="Rated 4 out of 5">
  <span aria-hidden="true">★★★★☆</span>
</div>
<!-- After: the hero picture is named by its visible caption -->
<div class="hero__image" role="img" aria-labelledby="hero-caption"></div>
<p id="hero-caption">Our workshop in Leipzig, spring 2026</p>

A purely decorative icon needs neither a role nor a name:

<i class="icon icon-sparkle" aria-hidden="true"></i>

How to test it manually

  1. Search the page source or the Elements panel for role="img".
  2. Select each element and open the Accessibility pane in developer tools (Chrome, Edge) or Firefox's accessibility inspector. Check the "Name" row.
  3. Compare the name with what you see: does it say what the graphic tells a sighted visitor? A star rating should read as a number, not as "stars".
  4. Listen with a screen reader (NVDA or VoiceOver). Decorative icons should be silent; informative ones should be announced once, with their meaning.

1.1.1 Non-text Content, Level A. Related: 1.3.1 Info and Relationships when the graphic stands in for structured information such as a rating, and 4.1.2 Name, Role, Value for the general rule that a role needs a name.

How Reviseberg reports it

Reviseberg runs role-img-alt on every crawled page at 1280px. The issue list shows the rule with its severity, WCAG criterion and level, the number of elements and pages affected, and the points you get back by fixing it. Ratings and badges usually come from one component, so a single fix often clears hundreds of occurrences; the detail view gives the CSS selector, the HTML snippet and every affected page.

You can mark a finding as "ignore", "can't fix" or "false positive" with a reason; every decision is logged. A clean result never marks 1.1.1 as passed on its own: whether each name is right is for a person to confirm.

  • undefined – <img> elements without a text alternative.
  • undefined – inline SVG with role="img" and no name; the SVG version of this rule.
  • undefined – ARIA attributes that are not allowed on the element's role.

Find unnamed graphics across your site – get a free scan

Frequently asked questions

Why doesn't the text inside the element count?

Because an element with role="img" takes its name only from the author – aria-label, aria-labelledby or title. Its content is treated as part of the picture.

Should I add role="img" to every icon?

No. Only to a group of elements that together form one meaningful image, such as a rating. Decorative icons are better hidden with aria-hidden="true".

Is a title attribute enough?

axe accepts it as the name. A title is not shown to keyboard or touch users, though, so aria-label or a visible caption with aria-labelledby is more dependable.

Sources

  1. W3C, Understanding SC 1.1.1 Non-text Content – https://www.w3.org/WAI/WCAG22/Understanding/non-text-content
  2. Deque University, axe-core 4.13 rule role-img-alt – https://dequeuniversity.com/rules/axe/4.13/role-img-alt
  3. W3C, WAI-ARIA 1.2: the img role – https://www.w3.org/TR/wai-aria-1.2/#img
  4. W3C WAI, Images Tutorial – https://www.w3.org/WAI/tutorials/images/

See what a scan finds on your site

One page in about thirty seconds, no email needed. The full report covers up to 100 pages and a keyboard journey.