Skip to main content
Raasta
SeriousWCAG 4.1.2 · Level Aaria-prohibited-attr

aria-label used where it isn’t allowed

aria-label and aria-labelledby are not allowed on elements with no role, such as a plain <div> or <span>, so many screen readers never read the label. Put the words in visible or visually hidden text instead, or give the element a role that can carry a name.

Who it hurts

Screen reader users, who hear the raw content (“★★★★½”, “−20%”) instead of the label you wrote.

Star ratings, prices and badges are the usual cases. The label looks right in the code but is silently dropped.

How to fix it

Pick your stack. Review every change before you ship it.

Before

<div aria-label="4.5 out of 5 stars">★★★★½</div>

After

<div>
  <span aria-hidden="true">★★★★½</span>
  <span class="visually-hidden">4.5 out of 5 stars</span>
</div>

Check it by hand too

Read the element with a screen reader. If you hear the visible content rather than the label, the label isn’t being used.

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