DEV Community

Daniel Pertu
Daniel Pertu

Posted on

The accessibility tree of our 38 pages has 1,091 named links, 151 pictures with no name, and one live region that never says a word

I have measured the accessibility of Notifio's website twice before, and both times with the wrong instrument. First by grepping the served HTML, which finds what we wrote. Then by pressing Tab 1,224 times, which finds what a keyboard does. Neither of those is what a screen reader reads.

What a screen reader reads is the accessibility tree, which the browser computes from the DOM, the CSS and its own rules. You can ask Chrome for it directly:

const cdp = await context.newCDPSession(page);
await cdp.send("Accessibility.enable");
const { nodes } = await cdp.send("Accessibility.getFullAXTree");
Enter fullscreen mode Exit fullscreen mode

38 pages later, that is 16,376 nodes.

The shape of the tree

Measurement Value
DOM elements inside body, 38 pages 8,041
Accessibility nodes 16,376
Nodes per element 2.04
Ignored nodes 1,747
Exposed nodes 14,629
Distinct roles 28
Roles on a single page 13 to 20
Biggest tree /terms, 724 nodes
Smallest tree /download, 252 nodes

More nodes than elements, because text is a first-class citizen in this tree: 3,988 StaticText nodes and 5,256 InlineTextBox nodes, one per rendered line fragment, are over half of everything.

The ignored nodes come in exactly three flavours:

uninteresting        1,639
presentationalRole      65
emptyAlt                38
Enter fullscreen mode Exit fullscreen mode

emptyAlt appearing 38 times, once per page, is the one image on the whole site being hidden correctly. We will come back to that number.

The half that is clean

The parts that the grep told me were fine are fine here too, which is a better result than it sounds, because the tree is where a missing label turns into a control a screen reader cannot describe.

Links                          1,091   named: 1,091
Buttons                           10   named: 10
Text fields                        5   named: 5
Controls with no accessible name    0
Headings                         402   one h1 per page, 38 of 38
Pages with a heading level skip     0
Native disclosures               119   all 119 carrying their question as the name
Enter fullscreen mode Exit fullscreen mode

119 DisclosureTriangle nodes are the FAQ, which is 119 <details> elements and no JavaScript, and all 119 arrive in the tree with the question as their name.

The 151 pictures nobody named

Here is the first real finding. The tree contains 151 nodes with the role image, and not one of them has a name:

image role nodes        151
with an accessible name   0
Enter fullscreen mode Exit fullscreen mode

The site has one actual image file, 550 bytes, and 157 inline SVGs. The one file is the node ignored 38 times for emptyAlt, which is correct: it is decorative and it says so. The 151 are SVGs that reach the tree as unnamed graphics, which a screen reader announces as "image" with nothing after it, or skips, depending on the reader and its settings.

They are not evenly spread:

/                                        24
/pricing                                 13
each of the five guides                   4
/terms /privacy /help /guides /compare /alerts /about   0
Enter fullscreen mode Exit fullscreen mode

The home page is the worst because it is the page with the most drawings on it, and seven pages have none at all. The fix is aria-hidden="true" on a decorative <svg>, which is one attribute per icon component and would delete 151 nodes from the tree rather than add anything to it. It is on the list, and the measurement is what moved it up.

For contrast, when I did this on a sibling site with 76 pages, the equivalent number was zero exposed graphics and 507 drawn paths the tree never saw, because those icons carry the attribute. Same designer, same year, different outcome, and the only way to know which one you have is to dump the tree.

229 sections and no regions

The second finding is a zero. The pages contain 229 <section> elements, and the tree contains no region nodes at all, because a section only becomes a landmark when it has an accessible name. Here is every landmark on the site:

main            38    one per page
contentinfo     38    the footer, one per page
navigation      69    38 unnamed + 31 named "Breadcrumb"
form             2    /pricing and /help
banner           0
region           0
complementary    0
search           0
Enter fullscreen mode Exit fullscreen mode

banner: 0 is the top bar. It is a <div>, so the thing holding the logo and the four nav links is not a landmark and cannot be jumped to. The 69 navigation landmarks are the nav in that div plus a breadcrumb on 31 pages; the seven without a breadcrumb are exactly the seven top-level pages, which is correct, because a breadcrumb to nowhere is worse than none.

So a reader using landmark navigation gets main, footer and nav on every page, and nothing for any of the 229 sections that organise the content inside them. Naming the ones that matter is an aria-labelledby pointing at the heading already sitting inside each.

The live region that has never said anything

There are 38 alert nodes, one per page, every one of them with an empty name and not focusable. We did not write them. The DOM on page load has zero role attributes anywhere on the site; this one arrives after hydration, from the framework's route announcer, whose job is to tell a screen reader that a soft navigation happened.

I measured what it actually says when you click a link: the URL, the title and the h1 all change in one animation frame and the announcement is nothing. So the tree has a megaphone on every page, pointed at nobody, and the measurement that found it empty at load is the same measurement that found it empty afterwards.

Four names that come from a placeholder

The contact form on the help page has four fields, and here is how the tree names them:

textbox   "Your name"
textbox   "you@example.com"
textbox   "e.g. Activation issue, billing question…"
textbox   "Describe your issue or question…"
Enter fullscreen mode Exit fullscreen mode

Those are placeholders, not labels. The accessible name falls back to the placeholder attribute when nothing better exists, which is why the audit says five named fields out of five and the honest reading is one labelled field out of five. A placeholder name has a specific failure mode: it is the name only until the reader types, and then the field is announced by its value and the question it was answering is gone.

The one properly labelled field is on the pricing page, and its name arrives in the tree like this:

textbox   "EMAIL ADDRESS"
Enter fullscreen mode Exit fullscreen mode

The markup says Email address. The shouting is a Tailwind uppercase class, and Chrome computes the accessible name from the rendered text, so the CSS gets a vote on what a screen reader says. It is announced as written in most configurations and spelled out letter by letter in some. One word of CSS, and the only correctly labelled field on the site has a name our source does not contain.

One more thing the tree found: two FAQs

The 119 native disclosures are on 30 pages. The help page is not one of them: its FAQ is six buttons with aria-expanded, and the answers are unmounted when closed rather than hidden. That is why turning JavaScript off loses 876 characters of FAQ answers and nothing else: those six. Two implementations of the same component, one of which needs a runtime and one of which does not, and the tree is where the difference stops being a style preference.

The home page's two buttons are the other curiosity. They are named "Start monitoring" and "Stop", and they belong to the animated mockup of the app rather than to the app. "Stop" really does stop the demo, so it is not a dead control, but nothing in the tree says that the thing it stops is a picture of a product. A group with a name would fix it, and the group is already there as an unnamed <section>.

Takeaways

  • Grep, Tab and the accessibility tree answer three different questions. The tree is the only one that tells you what the browser decided, including the things it decided to ignore.
  • "Every control has a name" and "every control has a label" are not the same sentence. Check where the name came from, because a placeholder counts as a name and stops existing when the field is used.
  • An unnamed <section> is not a landmark. Count your region nodes, not your <section> tags.
  • Decorative SVGs reach the tree as unnamed images unless you tell them not to. One attribute deletes the node; nothing in the HTML or a Tab sweep will show you the problem.
  • Accessibility.getFullAXTree over a sitemap is about 40 lines of script and gives you role counts, ignore reasons, heading levels and accessible names in one pass. If you only ever run one automated accessibility check, run this one.

Everything above is live and inspectable: the home page with its 24 unnamed drawings, the help page with the placeholder names, the pricing page with the shouted label, and the alerts catalogue, which scored a clean zero on every count in this post.

Top comments (0)