Skip to content

Lesson 5 of 9 · 26m

ARIA Done Right: Names, States, and the First Rule

The first rule of ARIA, how accessible names are computed, which attributes matter, and why unsupported widget roles are usually worse than native HTML.

The first rule of ARIA is not a joke: do not use ARIA if a native HTML element already does the job. ARIA does not add behavior. It changes what assistive technology is told. If you add role="button" to a div and forget keyboard handling, you have not made a button; you have made a lie.

Accessible names are computed, not guessed

<button aria-label="Close">×</button>
<label for="email">Email</label>
<input id="email" type="email">
<img src="chart.png" alt="Queue depth doubled after deploy">

The browser resolves names through a computation involving aria-labelledby, aria-label, native labels, alt text, and content. aria-labelledby wins over aria-label; both override text content. This is powerful and dangerous: a stale aria-label can hide the visible text entirely.

Use ARIA for states and relationships

Good ARIA usually answers one of three questions: what is this thing called, what state is it in, or what does it control or describe?

<button aria-expanded="false" aria-controls="advanced-panel">
  Advanced options
</button>
<div id="advanced-panel" hidden>...</div>

Keep the state synchronized. An aria-expanded="false" button that visibly opens a panel is worse than no attribute because it corrupts the interface contract.

Roles are contracts

A tablist is not just three styled buttons. It expects arrow-key movement, activation behavior, selection state, panels, and often manual versus automatic activation semantics. The same applies to comboboxes, menus, trees, and grids. Before choosing a role, read the corresponding WAI-ARIA Authoring Practices pattern and implement the whole contract — or use a library whose behavior you have verified.

Common ARIA failures in the wild

  • aria-label on a plain div that no one can interact with.
  • role="link" on an element that does not respond to Enter or open in a new tab contextually.
  • Redundant role="button" on an actual <button>.
  • aria-hidden="true" applied to content that still contains focusable controls.

Field notes

  • ARIA is a contract with assistive technology, not a hint.
  • Never use ARIA to “fix” a visual-only design when semantic HTML expresses the same thing.
  • Inspect the accessibility tree in Chromium or Firefox DevTools; do not infer names from markup by wishful thinking.
  • Icon-only buttons need names every time, even when the icon is “obvious” to your team.

Was this lesson helpful?

Sign in to rate