ARIA: When, Why and How Little
Learn what ARIA can and cannot change, how assistive technology computes an accessible name, and where a little ARIA — roles, states and live regions — earns its place.
Contentsand lesson path
On this page
- Why it matters
- What ARIA does not do
- How an accessible name is computed
- Live regions: announcing change
- Where ARIA earns its place
- Check your understanding
- Apply it
- Review prompt
Lessons of Web Accessibility
- Who Accessibility Serves and How WCAG 2.2 Is Organized Concept · 20 min
- Keyboard Access and Focus Management Worked example · 25 min
- ARIA: When, Why and How Little Concept · 20 min
- Accessible Dialog and Tabs, Step by Step Worked example · 30 min
- Lab: Audit with axe, a Keyboard and a Screen Reader Lab · 30 min
- Check: Triage Accessibility Defects Knowledge check · 8 questions
What you will learn
- Apply ARIA roles, states, properties and live regions only where native HTML falls short, and verify the result in the accessibility tree.
Prerequisites: Semantic HTML
01. Why it matters
WAI-ARIA is a vocabulary of roles, states and properties that adds semantics to elements: "this is a tablist", "this item is selected", "this region will update". It exists because semantic HTML cannot name every widget — there is no <tablist>, no <combobox>, no way to say "announce changes here".
To see why semantics are the whole game, remember the tree from the semantic HTML lab: browsers build a parallel accessibility tree from the DOM — every element becomes a node with a computed role, name and state — and screen readers, switch access and voice control consume that tree, not your CSS. ARIA is the vocabulary for adjusting that tree: changing a role, adding a state, naming a control.
The trap is believing ARIA does more than change semantics. It changes nothing else: no keyboard behaviour, no built-in events, no styling, no form participation. That gap is behind many of the worst accessibility failures, which is why the first rule in the W3C note Using ARIA (no longer updated, but kept for reference) is: if a native HTML element or attribute already has the semantics and behaviour you need, use it instead of adding ARIA.
02. What ARIA does not do
Here are two "buttons" in one page. The first is a div with the ARIA button role; the second is a <button>. Both are reachable with Tab and both say "Save". A click listener counts activations on each while a script presses Enter and then Space. The script needs Node and playwright 1.64.1 (npm install [email protected], then npx playwright install chromium); other versions may format the snapshot slightly differently. The whole page is printed in the next section:
<div id="div-save" role="button" tabindex="0">Save</div>
<button type="button" id="native-save">Save</button>import { chromium } from 'playwright';
import { pathToFileURL } from 'node:url';
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto(pathToFileURL('names.html').href);
await page.locator('#div-save').focus();
await page.keyboard.press('Enter');
await page.keyboard.press('Space');
await page.locator('#native-save').focus();
await page.keyboard.press('Enter');
await page.keyboard.press('Space');
const { divClicks, nativeClicks } =
await page.evaluate(() => window.counts());
console.log('div role=button ->', divClicks, 'clicks');
console.log('native button ->', nativeClicks, 'clicks');
console.log(await page.locator('main').ariaSnapshot());
await browser.close();div role=button -> 0 clicks
native button -> 2 clicksSame role, same name, same focusability — zero versus two activations. The role changed what assistive technology announces; the browser never granted the keyboard behaviour a real button has. Making the div work would mean writing keydown handlers for Enter and Space, aria-disabled support, form submission — reimplementing an element that already exists. That is the first rule of ARIA in one measured example.
03. How an accessible name is computed
The accessible name is the label assistive technology announces for a control, and it is computed in a fixed order of precedence: aria-labelledby first, then aria-label, then the element's own content, with alt for images and <label> for form fields in between. The page below adds a heading, two more buttons and an empty status region; the native Save button's click handler fills that region:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Names and roles</title>
</head>
<body>
<main>
<h1>Names and roles</h1>
<div id="div-save" role="button" tabindex="0">Save</div>
<button type="button" id="native-save">Save</button>
<button type="button" id="close" aria-label="Close dialog">
<svg width="16" height="16" aria-hidden="true"><!-- x --></svg>
</button>
<button type="button" id="cart"
aria-labelledby="cart-count cart-label">3</button>
<span id="cart-count" hidden>3</span>
<span id="cart-label">items in basket</span>
<p role="status" id="status"></p>
</main>
<script>
const counts = { divClicks: 0, nativeClicks: 0 };
const status = document.getElementById('status');
document.getElementById('div-save').addEventListener('click', () => {
counts.divClicks += 1;
});
document.getElementById('native-save').addEventListener('click', () => {
counts.nativeClicks += 1;
status.textContent = 'Changes saved'; // fills the region that already exists
});
window.counts = () => counts;
</script>
</body>
</html>The close button has no useful text content, so aria-label supplies the name. The basket button points aria-labelledby at two elements, and the referenced text wins over the content 3 — aria-labelledby also lets you concatenate ids in order, which aria-label cannot. The aria-hidden="true" on the icon keeps the drawing itself out of the tree. One caution when a control already has visible text: an aria-label replaces that text as the name, so the name must still contain the words people see. A button that shows Send but is named "Submit order" fails WCAG 2.5.3 Label in Name: a speech-input user who says "click Send" has nothing to match. That level A criterion asks only that the name contains the visible text; its note calls it best practice to start with it, so either drop the aria-label or write one such as "Send order". Here is what the browser reports for the whole page — the same tree a screen reader consumes:
- main:
- heading "Names and roles" [level=1]
- button "Save"
- button "Save"
- button "Close dialog"
- button "3 items in basket": "3"
- text: items in basket
- status: Changes savedRead that snapshot like a screen reader user: the two Save entries are indistinguishable — the tree cannot see class names or handlers — and every other control is named for what it does, not what it looks like. The last line is the live region, which the next section explains.
04. Live regions: announcing change
A live region tells assistive technology to watch an element and speak its changes. The two live region roles you will use most are role="status" (polite — speak when the user pauses) and role="alert" (assertive — interrupt, for errors that cannot wait); ARIA also has log, for histories such as chat. The same effect is available on any element through the aria-live attribute with values polite and assertive; the two roles are usually clearer, because they bundle the politeness level with the right semantics. The snapshot above shows status: Changes saved, produced by a region that sat empty in the page and was filled by script.
That empty-first detail decides whether the announcement happens at all. Screen readers watch regions that already exist; a region inserted into the DOM together with its message is usually missed. Render the container up front and update its text content, and keep live regions for messages the user did not request — anything that takes focus is not an announcement but a navigation. A page also needs very few of them: one well-placed status region near the main content beats a live region on every card.
05. Where ARIA earns its place
A short list, in the order to try things:
- Native first. A
<button>beatsrole="button", a<details>element beatsaria-expandedscripts, a heading beatsrole="heading". The semantic HTML lessons cover the native choices. - Native plus ARIA states. A real
<button>that opens a menu may still needaria-expandedandaria-controls, which HTML has no attribute for. - ARIA widgets for real gaps. Tabs, comboboxes, tree views, feed controls — where HTML offers no equivalent, follow the WAI-ARIA Authoring Practices pattern: roles and the complete keyboard interaction, together. The next lesson builds one.
However you use it, verify in the accessibility tree — the snapshot above came from one Playwright call, and your browser DevTools shows the same computed roles and names. The semantic HTML lab practises that inspection on a full page.
Two quiet details complete the picture. aria-hidden="true" removes an element and its subtree from the accessibility tree without hiding it visually — right for decorative icons, dangerous for interactive controls because keyboard users can still tab into controls that are completely hidden from screen readers. And every role you add is a promise you now maintain: if the component drifts from what the role claims, assistive technology keeps announcing the old story. That is the "how little" of this lesson's title — each ARIA attribute should carry its weight, and the tree is where you check that it does.
06. Check your understanding
07. Apply it
Pick three controls in a component library you use and open their accessibility tree snapshot in DevTools. For each, write down the computed role, name and state, and one sentence on whether ARIA was used where native HTML would have done. Then find one live update in an app you maintain, decide whether it is a status or an alert, and check whether its container exists before the update fires — the way the snapshot in this lesson did.
08. Review prompt
Without looking back: state the first rule of ARIA and explain what the 0-versus-2-clicks measurement showed. Recite the accessible name precedence in order, say why a live region must exist before its content changes, and name two widgets for which native HTML has no equivalent.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.