Rule
aria-label placement
aria-label or aria-labelledby on a plain container is prohibited by ARIA, so its announcement is not guaranteed.
- Rule
aria-label-misuse- WCAG 2.2
- 4.1.2 Name, Role, Value (opens in a new tab) (Level A)
- Severity
- Moderate
What it checks
WAI-ARIA forbids naming some roles with aria-label or aria-labelledby: plain containers such as <div>, <span> and <p>, and text elements such as <strong>, <em>, <code>, <del> and <ins>, or the same roles written out in a role attribute. The rule picks out these elements when they carry a label and have no other role and no tabindex.
A label inside a link, button, heading, table cell or other element that takes its name from its content passes. There the label does count: it becomes part of that element's name.
When a person decides
The rule never fails. Many browser and screen reader pairings announce the forbidden label today, but nothing guarantees it, and where it is announced it replaces the visible text. Markup that breaks ARIA is not by itself a WCAG failure, so a person needs to check that the content reads correctly both with the label and without it.
Example
Sent to review
<div class="price" aria-label="Was £30, now £24">
<s>£30</s> £24
</div>
Passes
<a href="/basket/">
<span class="icon-basket" aria-label="Basket"></span> 2 items
</a>
The engine is tested against both examples.
How to fix it
Put the words in real text, visible or visually hidden, rather than in a label the role does not allow. If the element plays a role of its own, such as a group or a landmark, give it that role; if the label is not needed, remove it.
Check your own pages
This rule runs in every pour audit: the browser extension, the bookmarklet, the command line and the editor. Get pour, free.