Elements with ARIA roles must have all required attributes
Some ARIA roles cannot work without specific states or properties, such as `aria-checked` for a checkbox or `aria-valuenow` for a slider. Add every attribute the role requires.
| Rule ID | aria-required-attr |
|---|---|
| Impact | Critical |
| Success criterion | 4.1.2 Name, Role, Value · A |
| Standards | WCAG 2.0 · WCAG 2.1 · WCAG 2.2 · Section 508 · EN 301 549 |
| Fixed automatically |
Example
<div role="checkbox" tabindex="0">
Gift wrap this order
</div>A screen reader says “Gift wrap this order, checkbox” but never says whether it is ticked.
<div role="checkbox" tabindex="0" aria-checked="false">
Gift wrap this order
</div>A screen reader says “Gift wrap this order, checkbox, not checked”, and updates when toggled.
Why it matters
A role tells assistive technology what kind of control an element is. The required attributes tell it the control's current state or value. A checkbox without aria-checked, a switch without on or off, or a slider without a value is announced as a control with no state. Blind users cannot tell if gift wrap is selected, whether a setting is on, or how loud the volume is, and they get no feedback when they change it.
Screen readers may also fall back to defaults or skip the control, so behaviour varies across software. Voice control and switch users, who act on the announced state, are affected in the same way. Missing state is one of the most common reasons custom widgets fail in real use.
How to fix it
Add the attributes the role needs, and update them in script whenever the state changes.
Common roles and what they require:
checkbox,radio,switch,menuitemcheckbox,menuitemradio:aria-checkedslider, focusableseparator:aria-valuenowcombobox:aria-expanded, andaria-controlswhile expandedheading:aria-levelscrollbar:aria-valuenow, plusaria-controlspointing at the scrolled areaoptionin a multi-select listbox: keeparia-selectedup to date
Example: a custom switch. Keep the attribute in sync:
<button type="button" role="switch" aria-checked="false" id="dark">Dark mode</button>
<script>
dark.addEventListener('click', () => {
dark.setAttribute('aria-checked', String(dark.getAttribute('aria-checked') !== 'true'));
});
</script>
Example: a custom heading.
<div role="heading" aria-level="2">Delivery options</div>
Native elements need fewer attributes. An <input type="checkbox" role="switch"> takes its state from checked, and <input type="range"> from its value. Where possible, switch to native elements and let the browser manage the state.
Checklist
- Look up the required attributes for each custom role.
- Add aria-checked to custom checkboxes, radios and switches.
- Give sliders aria-valuenow and headings aria-level.
- Update state attributes in script on every change.
- Prefer native inputs, which expose state automatically.
How the check works
The check looks at every element with an explicit role and lists the attributes the specification requires for it. It fails when one is missing and the HTML element does not supply it implicitly, as a native checkbox does. Some cases pass by exception: a non-focusable separator, a collapsed combobox without aria-controls, or a slider with aria-valuetext. Test that values update when users interact.
Resources
- Understanding 4.1.2 Name, Role, Value W3C
- W3C ACT rule 4e8ab6 W3C ACT
- Checkbox pattern ARIA Authoring Practices Guide
- Slider pattern ARIA Authoring Practices Guide
- Combobox pattern ARIA Authoring Practices Guide
- WAI-ARIA 1.2 specification W3C
Updated October 27, 2026