The accessibility tree and assistive technology model
Build semantic, accessible and responsive interfaces from a blank page, and explain why each layout and styling decision works.
What you will be able to do
#- Describe how the DOM maps to the accessibility tree.
- Inspect roles, names and states for a component.
Overview
#The accessibility tree is a parallel view of the DOM that browsers expose to assistive technology. Each node has a role, a name, a value and states. A <button> becomes a node with role button; its visible text becomes its name. A <div> with a click handler becomes a generic node with no role and no name, so a screen reader user has no idea it is interactive.
When you write semantic HTML, you are describing the accessibility tree. When you reach for ARIA, you are patching that tree by hand. The first rule of ARIA is not to use ARIA when a native element already provides the role, name and behavior. Native elements also come with keyboard interaction that ARIA does not add.
<!-- role button, name Subscribe, keyboard activation for free -->
<button>Subscribe</button>
<!-- no role, no name, no keyboard support -->
<div class="btn" onclick="subscribe()">Subscribe</div>
You can inspect the tree in browser DevTools: the accessibility panel shows each node's computed role, name and properties. That panel is the ground truth for whether a component is actually usable, more reliable than reading the markup and guessing. A component is accessible when its role, name and states in that tree match what a sighted user perceives.
Exercises
#Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.
Exercise 1Explain
Explain why a div with a click handler is not equivalent to a button, referring to the accessibility tree.
Reveal the reference answer
reference.textThe div has no role, so assistive technology does not announce it as a control, and it has no name unless one is added. It is also not focusable and does not respond to Enter or Space, so keyboard users cannot operate it. A button provides role, name from its text, focusability and activation keys natively.Authored expected output: An explanation that names at least role, name and keyboard activation as the missing pieces.
This is the core reason the first rule of ARIA is to prefer native elements.
Exercise 2Debug
This control is announced as 'button' but with no name. Fix the name without changing its role.
starter.html<button class="icon-btn"> <svg viewBox="0 0 16 16"><path d="M2 2h12v12H2z" /></svg> </button>Reveal the reference answer
reference.html<button class="icon-btn" aria-label="Close dialog"> <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 2h12v12H2z" /></svg> </button>Authored expected output: The button has an accessible name and the decorative svg is hidden from assistive technology.
An icon-only button needs a text alternative; aria-label supplies the name and aria-hidden keeps the decorative svg out of the tree.
Common misconceptions
#- Adding ARIA makes an element accessible.
- The accessibility tree is identical to the DOM.
Follow-up practice
#- html-css-12-keyboard-focus
Your progress
#Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.
Verification: authored. Answers and outputs on this page are authored reference material, not executed results.