The Accessibility Tree and Accessible Name Computation

The Accessibility Tree and Accessible Name Computation

Screen readers do not read the DOM. They read a parallel accessibility tree whose names come from the AccName algorithm. The priority chain, the DevTools workflow, and a 5-step debugging protocol.

Screen readers do not read the DOM. They read a parallel structure called the accessibility tree, which the browser builds from your HTML and ARIA; the name each node carries is computed by an algorithm called Accessible Name Computation (AccName). Many screen reader bugs are page bugs that the browser's DevTools accessibility tools can surface quickly — if someone on the team understands the algorithm. This guide covers the WCAG 4.1.2 contract, the AccName 1.2 priority chain, six worked examples across a button and a text field, the Chrome and Firefox tools, the most common bugs, and a debugging protocol you can teach the rest of your team.

The accessibility tree — what screen readers actually consume

Browsers maintain a parallel tree alongside the DOM and CSSOM — the accessibility tree. It contains a subset of the DOM, with each node carrying role, name, value, state, properties, and children. Screen readers and other assistive technology read the accessibility tree, not the DOM directly. A page can have correct DOM and broken accessibility tree, and that mismatch is what an ARIA bug is.

The tree is pruned aggressively. Elements hidden from everyone (display: none, visibility: hidden, the hidden attribute) drop out. aria-hidden subtrees drop out, except an element that currently has focus. Elements with role="presentation" lose their role and become semantically transparent, unless they are focusable or otherwise interactive, or carry a global ARIA state or property. Browsers can also collapse elements without semantic value (a <div> with no role and no children of interest). The result is a subset of the DOM that contains only the nodes relevant to assistive technology.

Each platform exposes the tree through its own accessibility API. Windows has two: MSAA with IAccessible2, and UI Automation. macOS uses its accessibility protocol (often called AX API); iOS has its own UIAccessibility layer (Apple accessibility documentation). Linux uses AT-SPI. Android uses AccessibilityNodeInfo. Screen readers consume the platform API and apply their own presentation rules on top, so the same page can announce differently across NVDA, JAWS, and VoiceOver even when the accessibility tree is identical.

The mental model that helps fix ARIA bugs is to stop thinking about what the DOM says and start thinking about what the accessibility tree says. The DOM is what you author; the accessibility tree is what users hear. The two are connected by an algorithm, not by identity.

Role, Name, Value — the WCAG 4.1.2 contract

WCAG SC 4.1.2 Name, Role, Value (Level A) requires that for all user interface components (including but not limited to form elements, links, and components generated by scripts) the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies. It dates back to WCAG 2.0, and failures of it, such as unnamed buttons and links, are among the most common issues in large-scale automated scans.

Role is what kind of thing this is. Button. Link. Checkbox. Heading. The role comes from the native HTML element's implicit role (<button> implies role="button") or from an explicit ARIA role= override. The role is what tells the screen reader how to announce the element and what keyboard contract to expect.

Name is the human-readable label that identifies the component. Save. Search. Email address. The name is computed by the AccName algorithm covered in the next section. A control with no name can be announced by its role alone (button, with nothing else), which the WebAIM Million 2024 ranks among the top WCAG failure categories under the labels empty button and empty link.

Value is the current state of a control. The checkbox is checked. The slider is at 50. The combobox is expanded. Value is conveyed through native state attributes (checked, value) or ARIA state attributes (aria-checked, aria-expanded, aria-valuenow). Static elements such as headings and plain text have no value; controls do. Links can be an exception: Firefox's Accessibility Inspector shows a link's href URL as its value (as of Oct 2026, Firefox source docs).

A frequent source of 4.1.2 failures is a custom widget — a <div onClick> that visually looks like a button — with neither a role nor a name nor a state contract. The first fix to try is use the native element; the <button> ships with all three for free.

The Accessible Name Computation algorithm (AccName)

The W3C Accessible Name and Description Computation 1.2 (AccName 1.2, a Working Draft as of Oct 2026) specifies how browsers compute the name. Browsers implement the same priority chain, and their results can still differ in edge cases.

The priority chain, highest wins:

  1. aria-labelledby — pointer to one or more elements whose own computed names (such as each element's aria-label, alt text, or text content) form the name
  2. aria-label — explicit string set on the element
  3. Native label association — <label for>, <fieldset><legend>, <table><caption>, alt on <img>
  4. For some elements only, descendant text content (a button's label, a link's link text)
  5. title attribute — used only when nothing above produces a name (for text inputs and <textarea>, the HTML-AAM spec still checks placeholder after title)

Two rules commonly trip teams up.

aria-labelledby beats everything below it, including the visible label. Use it sparingly — it overrides what the user can see, and that is a maintenance liability. Later, an editor changes the visible label and the announcement does not move because the announcement comes from the referenced element, not the visible content.

aria-label beats native label association. This is one way to introduce a divergent visible-and-announced experience. Use only when no visible label is feasible, which is the icon-only-button case and not much else. If your component has a visible text label, the visible text should be the accessible name, full stop.

The algorithm is recursive, with limits. When aria-labelledby points to an element, that element's own name is computed in turn — its aria-label, if it has one, takes precedence over its text and any image alt inside it — but an aria-labelledby on the referenced element is not followed again. Chained references can produce empty or unexpected names.

Worked examples — six markup patterns, two components

Six markup patterns — four for a Save button, two for a Full name text field — and the accessible name each one produces. Read each one against the priority chain.

html
<!-- 1. Native text content as name (cleanest pattern) -->
<button>Save</button>
<!-- name = "Save" (from descendant text content, step 4) -->

<!-- 2. aria-label overrides the visible text -->
<button aria-label="Save changes">Save</button>
<!-- name = "Save changes" (aria-label, step 2 — the visible/announced divergence problem) -->

<!-- 3. aria-labelledby overrides everything below it -->
<button aria-labelledby="save-instr">Save</button>
<span id="save-instr">Save changes to your profile</span>
<!-- name = "Save changes to your profile" (aria-labelledby, step 1) -->

<!-- 4. title as a fallback (works only when nothing above produces a name) -->
<button title="Save"></button>
<!-- name = "Save" from title (step 5). Fragile — title does not show on touch -->

<!-- 5. Native <label for> association on a form input (the right pattern for forms) -->
<label for="full-name">Full name</label>
<input type="text" id="full-name">
<!-- name = "Full name" (step 3, native label association) -->

<!-- 6. aria-label with a placeholder instead of a visible label -->
<input type="text" aria-label="Full name" placeholder="Enter your full name">
<!-- name = "Full name" but no visible label persists; placeholder disappears on input -->

Six cases, six trade-offs. Pattern 1 is the default answer for buttons. Pattern 5 is the answer for form fields. Pattern 2 is one option for icon-only controls; visually hidden text inside the button also works. Patterns 3, 4, and 6 are the patterns to look for in audits.

The accessibility tree in DevTools

You do not need a screen reader to inspect the accessibility tree. Every modern browser exposes it.

Chrome DevTools, Elements panel, Accessibility tab. Shows the selected node's ARIA attributes, its computed properties — including the computed role and name and what contributed to the name — and its position in the accessibility tree. The source of the name field is the single most useful field for debugging — it tells you exactly which step of the algorithm fired.

Chrome DevTools, Elements panel, Accessibility tree pane. Turn on Show accessibility tree in the Accessibility tab (as of Oct 2026, Chrome DevTools docs). It replaces the DOM tree in the Elements panel with the full-page accessibility tree, and you can toggle back at any point. Useful for spotting pruned nodes — anything that disappears between DOM and accessibility tree is being filtered out for one of the reasons covered in the pruning section below.

Firefox Accessibility Inspector. Its own Accessibility tab in the toolbox. Shows role, name, value, description, states, relations, and attributes, plus a Check for issues option that audits contrast, keyboard access, and text labels (as of Oct 2026, Firefox source docs).

Safari Web Inspector. Audit tab includes an accessibility audit; the Elements tab's Node panel shows the selected node's accessibility data. Useful for confirming how Safari builds the tree.

The team norm worth establishing: open DevTools accessibility before reporting an ARIA bug. Confirm the computed name matches what the screen reader announces. If they match, the bug is in the page; if they differ, check the screen reader version and settings before suspecting the screen reader itself. Many screen reader announces wrong tickets are resolved at the DevTools level.

Common AccName bugs and how to debug them

A short catalog of the bugs that recur across audits, with the root cause for each.

BugRoot causeFix
Button announces only its roleNo name from any source — no descendant text or image `alt`, no `aria-label` or `aria-labelledby`, no associated ``, no `title`Add visible text or `aria-label`
Button announces "Search Search"`aria-labelledby` lists both the button itself and a label element containing the same wordReference one source of the name, not both
Link announces label and a URL`title` attribute set to the URL is exposed as the accessible description, which screen readers can read after the nameRemove the `title`
Input is unlabeled despite a visible label`` is not associated to the input (missing `for=`, or input not a descendant of ``)Associate via `` or wrap the input
Fieldset reads only the legend per radioEach radio has no `` — the legend names the group, but each radio itself has no nameAdd `` per radio inside the fieldset
Heading on `` announced at the wrong levelMissing `aria-level` — ARIA 1.2 tells browsers to treat a missing level as 2Use a real heading element at the right level

The <fieldset><legend> case is worth dwelling on because the fix is non-obvious. The legend supplies the group name, but each individual radio still needs its own <label>. The right pattern is:

html
<fieldset>
  <legend>Color</legend>
  <input type="radio" id="red" name="color" value="red">
  <label for="red">Red</label>
  <input type="radio" id="blue" name="color" value="blue">
  <label for="blue">Blue</label>
</fieldset>

A screen reader announces each radio along the lines of Red, radio button, 1 of 2, Color group — the legend supplies the group context, the label supplies the choice. Skip the per-radio label and each option is announced with no name of its own — at best the user hears the group name and radio button — which is unusable.

When the tree is pruned — and how to control pruning

Pruning explains why an element can be missing from the accessibility tree. There are five mechanisms to know.

aria-hidden="true" removes the element and its descendants from the accessibility tree — except that an element that currently has focus is still included, even when it or an ancestor has aria-hidden="true". Use for visual decoration that has no programmatic meaning — a decorative icon next to an already-labeled button, a background flourish. Catastrophic on focusable elements; covered as the headline ARIA misuse pattern in our ARIA misuse guide.

role="presentation" (or its synonym role="none") strips the role from the element but leaves descendants intact — unless the element is focusable or otherwise interactive, or has a global ARIA state or property, in which case browsers ignore the presentation role and expose the element's implicit role. Use to make a wrapper element semantically transparent. On elements with required children, the effect carries down — applying role="presentation" to a <table> also strips the semantics of its rows and cells unless they carry an explicit role; the ARIA spec calls this presentational role inheritance.

display: none and visibility: hidden both remove the element from the accessibility tree. content-visibility: hidden also removes the element's contents (the element itself stays). content-visibility: auto skips rendering off-screen content; if a browser skips that work for display, the CSS Containment spec requires it to skip the same work for the accessibility tree, and to omit the skipped content from the tree entirely when that is not possible. The CSS choices have accessibility-tree consequences that authors may not consider until a screen reader can not find an offscreen menu.

The inert attribute (HTML standard; Baseline since 2023, Widely available as of Oct 2025 per web-features) is a more declarative way to remove a subtree from the accessibility tree and the tab order. Replaces the manual aria-hidden plus tabindex="-1" patterns of the past. A common choice for custom dialogs (mark everything outside the dialog inert; a native <dialog> opened with showModal() does this automatically) and offscreen menus.

The visually-hidden but accessible utility — the .visually-hidden or .sr-only pattern using clip-path or position: absolute; width: 1px; height: 1px. The element stays in the accessibility tree, screen readers read it, sighted users do not see it. The right pattern for skip-link text and labels that should be announced but not displayed. Not the same as display: none, which removes the element entirely.

A debugging protocol for "announces the wrong thing"

When a tester reports that the screen reader announces something wrong, run this protocol before filing a screen reader bug. It often resolves these tickets at the page level.

Step 1 — open Chrome DevTools, select the offending element, read the Accessibility tab. Note the computed name, computed role, and the source of the name. Write all three down before doing anything else.

Step 2 — confirm the source matches what you expect. If the source says Contents but you set aria-label, the aria-label is being ignored — usually because the element's role does not allow naming (a plain <div> or <span> with no role, or roles such as paragraph). Give the element a nameable role, or use a native element.

Step 3 — disable each ARIA attribute one at a time. Toggle them off in DevTools and watch the recomputed name and source change. The attribute whose removal fixes the announcement is the bug.

Step 4 — verify in Firefox Accessibility Inspector. If Firefox computes a different name from Chrome, you may have found a place where browsers interpret the spec differently — or a browser bug. File a browser bug if the divergence is real and pick a less ambiguous pattern in the meantime — usually a native HTML element instead of an ARIA-overridden one.

Step 5 — only after the computed name is correct in DevTools, retest with the screen reader. If the screen reader still announces wrong, the bug is in the screen reader (or the platform AT API mapping), not in the page. Now you have a defensible bug report that includes the DevTools-confirmed correct accessible name and the divergent screen reader announcement.

The accessibility tree is not a black box. It is the platform layer beneath ARIA, and the algorithms that build it are documented and inspectable. Teams that internalize the priority chain and the DevTools workflow can separate markup bugs from screen reader bugs before filing them, which leaves more time for the screen reader testing that genuinely needs to happen.

Project Inquiry