Skip to content

Accessibility Notation ​

With SPECCER, you can also display accessibility notation, like Accessibility Bluelines or A11y Annotation Kit:

Prior art: Jeremy Elder and Stephanie Hagadorn

INFO

For more technical documentation, see the relevant documentation under the API-section.

Usage ​

Via <script>-tag ​

index.html
html
<script src="https://unpkg.com/@phun-ky/speccer/dist/speccer.js"></script>
<div data-speccer="a11y tabstops|landmark|headings|autocomplete|shortcut">
  …
</div>

Programmatically ​

html
<div data-speccer="a11y tabstops|landmark|headings|autocomplete|shortcut">
  …
</div>
typescript
import { a11y } from '@phun-ky/speccer';

a11y();

Lazy loading

With data-lazy or modes.lazy(), accessibility annotations aren't drawn yet. See troubleshooting for a workaround.

Tab Stops ​

Screenshot of speccer a11y tab stops in use

If you want to display tab stops, append data-speccer="a11y tabstops" as an attribute to the container you want to display the tab stops in. The tab stops are numbered in the order the Tab key visits them: positive tabindex values first, then the rest in document order. A group of radio buttons is one tab stop, on the checked radio, or the first one when none is checked.

Tab Order Path ​

Add path to draw a line from each tab stop to the next:

html
<div data-speccer="a11y tabstops path">…</div>

When focus moves against the reading order, up or back along a row, the line is dashed and red. That may break WCAG 2.4.3 Focus Order. The color is --ph-speccer-a11y-tabstops-backwards-color.

The lines need the #ph-speccer-svg element in the document.

Landmarks And Regions ​

Screenshot of speccer a11y landmarks in use

If you want to display landmarks and regions, append data-speccer="a11y landmark" as an attribute to the container you want to display the landmarks and regions in.

Headings ​

Screenshot of speccer a11y headings in use

If you want to display headings, append data-speccer="a11y headings" as an attribute to the container you want to display the headings in.

Autocomplete ​

Screenshot of speccer a11y autocomplete in use

If you want to display autocomplete, append data-speccer="a11y autocomplete" as an attribute to the container you want to display the autocomplete in.

Contrast ​

If you want to check the text contrast, append data-speccer="a11y contrast" as an attribute to the container. Each element with its own text gets a label with its WCAG 2 contrast ratio and the level it meets:

LabelNormal textLarge text
AAA7:14.5:1
AA4.5:13:1
Fail, redbelow 4.5:1below 3:1

Large text is 24px or more, or 18.66px (14pt) or more and bold. The ratio is truncated, not rounded, so 4.499:1 shows as 4.49:1 and fails.

The background is found by blending the background colors of the element and its ancestors, down to the first opaque one, or white. The label is ? when that can't tell the color behind the text: over a background image or gradient, or with opacity below 1. Content painted behind the text from elsewhere, like an absolutely positioned element, isn't seen either, so check those by eye.

Keys And Shortcut ​

Screenshot of speccer a11y shortcuts in use

If you want to display the shortcut with keys used for elements, use data-speccer="a11y shortcut" and data-speccer-a11y-shortcut="<shortcut>" on the element that uses this shortcut:

html
<button
  type="button"
  data-speccer="a11y shortcut"
  data-speccer-a11y-shortcut="ctrl + s"
>
  Save
</button>