Lesson 2 of 30
A screen reader never looks at your CSS. It queries a separate tree the browser builds from the DOM, and understanding that tree is the difference between guessing at accessibility and actually diagnosing it.
13 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A div is styled with CSS to look exactly like a toggle switch and has a click handler attached. What is most likely true about its accessibility tree node?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Alongside the DOM, the browser builds a second tree: the accessibility tree. It's derived from the DOM, but it isn't the DOM — it strips out everything assistive technology doesn't need (styling, layout, most structural nesting) and keeps only what a screen reader actually queries: for each node, its name (what gets announced), role (what kind of thing it is — button, link, heading, list), state (checked, expanded, disabled), and value (a slider's current number, an input's current text).
This single fact resolves a lot of confusing behavior once you know it: a screen reader doesn't read your page visually and it doesn't parse your CSS. It queries the accessibility tree. That means two things are true at once, and they're genuinely independent of each other:
display: none, or an off-screen "sr-only" utility class) can still be fully announced, if it's present in the accessibility tree — this is exactly how visually-hidden helper text for screen readers works on purpose.<button>, or a correctly-implemented ARIA equivalent) do that.Visual presentation and accessibility-tree presence are two separate systems. Getting one right says nothing about the other.
The DOM and the accessibility tree are two separate trees built from the same page — a screen reader only ever queries the second one.
The reliable way to know what a screen reader will actually announce isn't to guess from reading markup — it's to look at the accessibility tree directly. Chrome DevTools has this built in: open the Elements panel, select an element, then open the Accessibility pane in the sidebar. It shows the computed name, role, and state for that exact node, generated the same way a screen reader would consume it.
<!-- Looks like a button. Isn't one to the accessibility tree. -->
<div class="btn" onclick="deleteItem()">Delete</div>
<!-- Real button: name "Delete", role "button", focusable, keyboard-operable -->
<button onclick="deleteItem()">Delete</button>
Both divs render identically. Inspect the first one in DevTools' Accessibility pane and there's often no meaningful node there at all — generic, no role, no interactive semantics. Inspect the second and you'll see name: "Delete", role: "button" — exactly what a screen reader needs to announce "Delete, button" and let a user activate it.
display: none removes an element from both the visual render and the accessibility tree. An "sr-only" class that clips visually but keeps the element rendered keeps it in the accessibility tree — that distinction is exactly how visible-only and screen-reader-only content are built on purpose."How would you actually verify what a screen reader announces for this component, without a screen reader installed?" tests whether a candidate knows the accessibility tree exists as a distinct, inspectable layer — naming Chrome DevTools' Accessibility pane as a concrete diagnostic step is a strong, specific signal over a vague "I'd test it with a screen reader" answer.