Free, independent guides since 2010

Accessibility

ARIA basics: when and how to use it

An introduction to WAI-ARIA for web developers: the first rule of ARIA, roles, states and properties, accessible names, live regions, common patterns like disclosure and tabs, and frequent mistakes.

<guide section="Accessibility" type="article" read="1 min"/>

WAI-ARIA (Accessible Rich Internet Applications) is a W3C specification that lets you describe custom interface components to assistive technology. It is powerful – and frequently misused. Know the basics before you use it.

The first rule of ARIA

If a native HTML element or attribute has the semantics and behaviour you need, use it instead of adding ARIA. A <button> is better than <div role="button" tabindex="0"> with keyboard handlers.

Three kinds of ARIA attributes

KindExamplesPurpose
Rolesrole="dialog", role="tablist"What the element is
Statesaria-expanded, aria-selected, aria-invalidCurrent condition
Propertiesaria-label, aria-describedby, aria-controlsNames and relationships

Common pattern: a disclosure button

HTML
<button type="button" aria-expanded="false" aria-controls="faq1">Shipping costs</button>
<div id="faq1" hidden>Free above €50 in Belgium.</div>
<script>
const b = document.querySelector('[aria-controls="faq1"]');
b.addEventListener('click', () => {
  const open = b.getAttribute('aria-expanded') === 'true';
  b.setAttribute('aria-expanded', String(!open));
  document.getElementById('faq1').hidden = open;
});
</script>

The mega menu on this site uses the same principle: tab buttons with aria-expanded and aria-controls.

Live regions

HTML
<p class="status" role="status">Product added to your cart</p>

Content changes inside a status region are announced without moving focus.

Frequent mistakes

  • aria-hidden="true" on focusable or important content.
  • aria-label that contradicts the visible text.
  • Roles without the matching keyboard behaviour.
  • States that are never updated by JavaScript.

Use the W3C’s ARIA Authoring Practices Guide for tested patterns.

Frequently asked questions

Does adding ARIA make my site accessible?

Not by itself. ARIA only changes what assistive technology is told; it does not add keyboard behaviour or fix design. It must match how the component really works.

What is an accessible name?

The name assistive technology announces for an element, such as a button’s text, a label, alt text or an aria-label.