WAI-ARIA Foundations & The Accessibility Tree

WAI-ARIA Foundations & The Accessibility Tree in HTML: WAI-ARIA (Web Accessibility Initiative - Accessible Rich Internet Applications) is a W3C specification…

WAI-ARIA (Web Accessibility Initiative - Accessible Rich Internet Applications) is a W3C specification providing extra semantic semantics to bridge the gap between complex web user interfaces and assistive technologies (such as screen readers NVDA, JAWS, VoiceOver, and TalkBack).


The First Rule of ARIA

Rule #1 of ARIA: If you can use a native HTML element or attribute with the semantics and behavior you require, DO NOT repurpose an element and add ARIA to make it accessible.

<!-- BAD: Re-inventing a button with div and ARIA (requires manual Enter/Space listeners!) -->
<div role="button" tabindex="0" onclick="submit()">Submit</div>

<!-- GOOD: Native semantic button has built-in keyboard accessibility and focus management -->
<button type="button" onclick="submit()">Submit</button>

The Accessibility Tree & AOM

Browsers translate your HTML document into two distinct trees in memory:

  1. The DOM Tree: Used for layout, CSS rendering, and JavaScript execution.
  2. The Accessibility Tree: A stripped-down hierarchy consumed by assistive technology containing:
  • Role: What the object is (e.g., button, link, dialog, checkbox).
  • Name: The human label of the object.
  • State: Whether it is expanded, pressed, disabled, or checked.
  • Value: The current numerical or textual progress.

Accessible Name Computation

Every interactive element MUST have an accessible name calculated by the browser:

<!-- 1. Text Content (Default) -->
<button>Save Changes</button> <!-- Name: "Save Changes" -->

<!-- 2. aria-label (Overrides all text content!) -->
<button aria-label="Close dialog modal">✕</button>

<!-- 3. aria-labelledby (References visible text elsewhere) -->
<span id="opt-label">Enable Two-Factor Authentication</span>
<button role="switch" aria-checked="false" aria-labelledby="opt-label"></button>

<!-- 4. aria-describedby (Provides auxiliary helper instructions) -->
<input type="password" id="pass" aria-describedby="pass-rules">
<p id="pass-rules">Password must be at least 12 characters long.</p>

Hiding Content from Screen Readers: aria-hidden

When an element is purely decorative (such as a visual SVG icon beside a label), hide it from the accessibility tree so screen readers don't announce redundant characters:

<button>
  <svg aria-hidden="true" focusable="false" width="16" height="16">...</svg>
  <span>Download Invoice</span>
</button>

Exercises

  1. Inspect the Accessibility panel in Chrome DevTools to verify the Accessible Name of interactive components on a landing page.
  2. Explain the difference between aria-label, aria-labelledby, and aria-describedby.
  3. Identify three instances where native HTML elements should replace ARIA roles.