Accessibility Tree Overview
How browsers build the accessibility tree from DOM and CSS — roles, names, states, what’s pruned, and how to inspect it in DevTools.
- html
- accessibility-tree
- a11y
Screen readers and other assistive tech don’t read your raw HTML string. They walk the accessibility tree — a derived structure of roles, names, values, and states built from the DOM, certain CSS, and ARIA. If a node isn’t in that tree, users who rely on AT may never know it exists.
Docs: MDN accessibility tree, Chrome a11y tooling, ARIA in HTML.
From DOM to a11y tree
Rough pipeline:
- Parse HTML → DOM
- Apply styles → determine visibility/display
- Compute accessible objects with roles and properties
- Expose via platform APIs (macOS AX, Windows UIA/IA2, etc.)
<button type="button" aria-expanded="false" aria-controls="menu">
Menu
</button>
<ul id="menu" hidden>…</ul>
The button appears as a button role, name “Menu”, state collapsed. The hidden list is omitted or marked hidden depending on the hidden/CSS path.
What gets pruned
Typically not exposed as interesting accessible nodes:
- Elements with
display: noneorvisibility: hidden(with nuances) hiddenattribute /aria-hidden="true"(descendants ignored for AT — careful)- Purely decorative elements with proper patterns (
alt="",role="presentation"where valid) - Some presentational children of certain roles
<!-- Decorative -->
<img src="/swirl.svg" alt="" />
<!-- Mistakenly hidden from AT -->
<div aria-hidden="true">
<button type="button">Checkout</button> <!-- disaster -->
</div>
Never put focusable controls inside aria-hidden="true" regions.
Name, role, value
Every interactive control needs a role (often native), an accessible name, and relevant states/values.
| Piece | Sources |
|---|---|
| Role | Native element (button, a, input) or ARIA role |
| Name | Content, <label>, aria-label, aria-labelledby, alt, … |
| State | disabled, aria-expanded, aria-checked, validity, … |
<label for="email">Email</label>
<input id="email" name="email" type="email" autocomplete="email" />
Name comes from the label association — better than aria-label alone for visible text.
Inspecting
- Chrome/Edge: Elements → Accessibility pane
- Firefox: Accessibility Inspector
- Safari: Develop → Show Web Inspector → Node → Accessibility
Verify:
- Is the control present?
- Is the name what you expect?
- Are states updated when the UI changes?
- Does the order match a sensible reading order?
HTML first, ARIA second
Native elements ship correct roles and keyboard behavior:
<!-- Prefer -->
<button type="button">Delete</button>
<!-- You must rebuild name, role, keyboard, disabled -->
<div role="button" tabindex="0">Delete</div>
ARIA can fix gaps; it can’t put back default keyboard semantics you threw away without extra JS.
Interview out-loud
“The accessibility tree is the browser’s AT-facing structure of roles, names, and states derived from DOM and styles. Hidden CSS and aria-hidden prune nodes. I inspect it in DevTools when a control isn’t announced, prefer native elements for free roles, and ensure every interactive control has a computed accessible name.”
Footguns
- Icon-only buttons with no name.
aria-hiddenon live regions or focused ancestors.- CSS that visually shows content but removes it from the tree (or the reverse with off-screen hacks).
- Duplicate names from both visible label and
aria-label. - Assuming the DOM order always matches the a11y order with CSS grid reordering — test.
Related
- Semantic HTML
- ARIA labels and descriptions
- What is the accessibility tree
- Accessible names computation
Further reading
- Accessibility tree — MDN Glossary
- Accessible Name and Description Computation
- Chrome DevTools accessibility
Related guides
- Images alt and DecorativeWrite useful alt text, mark decorative images correctly, and avoid SEO/a11y anti-patterns like keyword stuffing or missing alt.
- Landmark Elementsheader, nav, main, aside, footer landmarks — how AT users jump sections, labeling multiple navs, and common landmark mistakes.
- Tables for Tabular DataUse tables for data grids — th/scope, captions, headers, responsive strategies, and when CSS grid is the wrong substitute.
- Semantic HTMLPick elements for meaning, not looks — landmarks, headings, forms, media, and how semantics feed a11y and SEO.
- Audio and Video ElementsNative audio/video — controls, sources, captions, autoplay policies, and accessibility requirements for media on the web.