Rule

Valid roles

role attributes must use valid ARIA roles.

Rule
valid-role
WCAG 2.2
4.1.2 Name, Role, Value (opens in a new tab) (Level A)
Severity
Critical

What it checks

The rule reads every role attribute. A role passes when at least one of its tokens is a role WAI-ARIA defines, including the digital publishing and graphics modules. Otherwise the browser ignores it and the element keeps its native role. The rule fails a plain element, such as a <div> or <span>, with an invalid role when it takes focus or carries ARIA states: a control built that way reaches assistive technology with no role at all. A near miss, such as role="buton", is named in the result with the role it most likely meant.

When a person decides

An invalid role on an element with native semantics of its own, such as a heading or a native button, is sent for review, and so is one on an element that takes no focus and carries no ARIA states. The element is exposed with its native role, so nothing is announced wrongly, but a person checks whether a different role was meant. A plain <div>, <span> or <svg> of that kind passes, since it loses nothing.

Example

Fails

<div role="buton" tabindex="0">Add to basket</div>

Passes

<div role="button" tabindex="0">Add to basket</div>

The engine is tested against both examples.

How to fix it

Correct the role to one WAI-ARIA defines, such as role="button", or remove the attribute and use the native element, such as <button>.

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.