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 IDaria-required-attr
ImpactCritical
Success criterion 4.1.2 Name, Role, Value · A
StandardsWCAG 2.0 · WCAG 2.1 · WCAG 2.2 · Section 508 · EN 301 549
Readabler fix Fixed automatically

Example

Before
<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.

After
<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-checked
  • slider, focusable separator: aria-valuenow
  • combobox: aria-expanded, and aria-controls while expanded
  • heading: aria-level
  • scrollbar: aria-valuenow, plus aria-controls pointing at the scrolled area
  • option in a multi-select listbox: keep aria-selected up 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

  1. Look up the required attributes for each custom role.
  2. Add aria-checked to custom checkboxes, radios and switches.
  3. Give sliders aria-valuenow and headings aria-level.
  4. Update state attributes in script on every change.
  5. 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

Updated October 27, 2026