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
| Kind | Examples | Purpose |
|---|---|---|
| Roles | role="dialog", role="tablist" | What the element is |
| States | aria-expanded, aria-selected, aria-invalid | Current condition |
| Properties | aria-label, aria-describedby, aria-controls | Names and relationships |
Common pattern: a disclosure button
<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
<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-labelthat 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.