Focus trail and heading outline drawn by a canvas

Two accessibility views from the element catalogue, and two more on the same form. A canvas draws a form and, when focus moves, a ring that travels from the control that lost focus to the one that gained it. The same canvas can mark the size of each touch target and draw a line from each label to its control. A second canvas draws an article with a list of its headings beside it. Each row of that list is the heading's own pixels, drawn a second time.

Focus ring that leads the eye

Tap a field or a button in the form, press Tab, or use "Next stop". The ring flies from the old position to the new one and the rest of the form is shaded. "Target sizes" and "Label lines" draw two more views over the same form.

The canvas learns that focus moved from focusin, which names both elements. It reads where each one was drawn from getBoundingClientRect(). When the ring arrives, the canvas draws that rectangle of the form's picture a second time, 12% larger, for a third of a second. The form has four faults on purpose: a 20 px button, a field with only a placeholder, a label whose for matches nothing, and the field that label was meant for.

Show the code focusin, two rectangles, and a ring drawn between them
  1. The markup. One drawable form. Nothing in it is there for the views.
  2. Hearing that focus moved.
  3. One frame of the ring.
  4. The paint handler. The form, then the views, then the ring.
  5. Drawing the focused control enlarged. A piece of the form's picture, and a draw with no ink to put the hit box back.
  6. The shade, the tail and the ring.
  7. Target sizes.
  8. Label lines.
  9. Styles.

Heading outline beside the page

Scroll the article with a finger or the wheel. The list on the right has one row for each heading. Tap a row to go to that heading. Change a heading with the controls under the picture and its row changes, because the row is drawn from the article's picture.

Heading levels in a document

This article is a child of the canvas. The list beside it is drawn by the canvas from the headings below.

What a level means

The elements h1 to h6 give a heading a level from 1 to 6. A heading starts a section. The section ends at the next heading of the same level or of a level with a lower number.

Nesting

An h3 that follows an h2 starts a part of the h2 section. The outline indents it and draws a line to its parent.

Skipped levels

A heading two or more levels below the one before it leaves a gap in the outline. The control under the picture changes this heading to an h5. The outline then marks its row in red. See Listing every heading.

How a screen reader uses headings

Headings are a way to move through a page without reading all of it.

Moving by heading

A screen reader can move from one heading to the next. TalkBack on Android does this when its reading control is set to "Headings".

Listing every heading

Some screen readers show all headings of the page in a list, with their levels. The rail beside this article is the same list, drawn. Back to Skipped levels.

Elements that count

The outline collects h1 to h6 and every element with role="heading".

A div with role="heading"

The line above is a div. Its level comes from aria-level. With no aria-level the level is 2.

What the outline leaves out

A heading that is not rendered, or is inside aria-hidden="true" or inert, is left out. Shadow trees and frames are not followed.

The rows aren't text drawn by the canvas. Each one is drawElementImage(article, sx, sy, sw, sh, dx, dy, dw, dh) with the rectangle of one heading, so the font, the wrapping and any edit are the article's. The links that take the taps are children of the canvas drawn with globalAlpha = 0. Scrolling is the browser's own: the canvas is position: sticky inside a scroll container and draws the article at minus scrollTop.

Show the code headings from the DOM, rows from the article's picture
  1. The markup. A scroll container, a sticky canvas, the article and an empty list.
  2. Collecting the headings.
  3. One link per heading.
  4. Where each heading is in the article.
  5. The paint handler. Links with no ink, the rail, then the article.
  6. Drawing the rail.
  7. Going to a heading.
  8. Styles.

How it works

Live checks

Each check builds a small canvas of its own in a corner of the window. The checks that move focus run in a hidden copy of this page. The two pictures above aren't touched.

ResultExperimentDetail

Findings

From Chromium 157, headless, on 2026-11-21. The rows above say what your browser does. Real key presses and touch events were sent by tools/a11y-views/check.mjs.