Rule
Required role states
Some roles require a state attribute to work.
- Rule
role-required-aria- WCAG 2.2
- 4.1.2 Name, Role, Value (opens in a new tab) (Level A)
- Severity
- Serious
What it checks
Some ARIA roles only make sense with a state or value beside them. The rule fails an element given one of these roles without it: checkbox, radio, switch, menuitemcheckbox and menuitemradio without aria-checked; slider, meter and scrollbar without aria-valuenow; heading without aria-level; and combobox without aria-expanded. A separator needs aria-valuenow only when it takes focus, since that makes it a control for resizing.
A native element that supplies the state itself passes, such as <input type="checkbox" role="switch">, whose checked state the browser already exposes.
When a person decides
A missing aria-selected on an option, or a missing aria-controls on a scrollbar or an open combobox, is sent for review. WAI-ARIA lists both as required, but selection is often conveyed by focus alone and the link from a control to what it operates is rarely announced, so a person checks the control works with a screen reader.
Example
Fails
<span role="checkbox" tabindex="0">Send me order updates</span>
Passes
<span role="checkbox" tabindex="0" aria-checked="false">Send me order updates</span>
The engine is tested against both examples.
How to fix it
Add the attribute the role needs, such as aria-checked="false", and update it from script as the state changes. A native element, such as <input type="checkbox">, supplies the state without 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.