Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Audit a Page for Accessibility

In this lesson, you put the checks from the last three lessons together into a four-step accessibility audit of the work day sign-up page, and saw what Lighthouse’s automated score can’t see.

Key Points

  • An audit is four checks, in this order:
  • The keyboard needs no tools and finds what a visitor can’t reach. Click the site name, press Tab, and follow the outline. Then operate each control with its keys. The arrow keys pick a task in the group, Space ticks the gloves checkbox, and Shift+Tab takes you back up the page. Check contrast in error states and zoom here too, as in Check Contrast and Zoom, because Lighthouse sees only the page as it loads.
  • The Accessibility pane shows what a screen reader will be told. Inspect each control you tabbed to: its role and name should match what a visitor sees. Email is a textbox named by its label, Email (required), with its error message as the description, and the Sign up button is a button, named by its own text, Sign up.
  • Lighthouse runs the checks a machine can measure. In DevTools, open the Lighthouse panel, tick only Accessibility, and click Analyze page load. It reloads the page, checks things like labels, names, contrast, and language, and scores the page from 0 to 100.
  • A screen reader confirms it all by ear. The steps are in Your Own Screen Reader Pass below.
  • The keyboard and the pane come first, before Lighthouse, so a Lighthouse 100 can’t talk you out of them.
  • The keyboard found Tomás’s change. He gave the nav’s last item order: -1 so About shows first, the same rule you tried in Use the Page With the Keyboard Alone. Tab went Home, Plots, Volunteers, Events, Work Day, Seed Swap, then jumped back to About at the front, because CSS moved the box but not its place in the HTML.
  • Lighthouse gave that page 100. It never presses Tab, so it couldn’t see focus jump backward. Under the score, it lists ten Additional items to manually check, among them Visual order on the page follows DOM order, the order of the HTML.
  • A Lighthouse 100 means every check Lighthouse scores has passed, like a test suite that proves only what it tests. It doesn’t mean every visitor can use the page. The same page also scores 100 with its focus outline removed, or with Sign up turned into a <div>. It’s one check passed out of four.
  • To fix it, take out the order: -1 rule. If Rosa still wants About first, move its <li> to the top in the HTML.
  • Chrome’s full accessibility tree is what a screen reader reads. The sign-up page has four landmarks: the header (banner), the nav (navigation), main, and the footer (contentinfo). Inside main, each form field has its role and name.

Your Own Screen Reader Pass

Run a short pass with a screen reader on the sign-up page you built. On a Mac, use VoiceOver, which comes with macOS. On Windows, use Narrator, which comes with Windows, or NVDA, a free download.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 Rosa wants to share the sign-up page with the volunteers. Over three lessons, you checked it one way at a time, with the keyboard, by its names, and for contrast and zoom.

00:11 Since then, Tomás has made one change, the rule you tried with the keyboard a few lessons back. Rosa asked for About to come first in the nav, so he gave its list item order: -1 in CSS.

00:24 As a programmer, you might run the automated tests and ship when they pass. Chrome has a tool like that for accessibility, called Lighthouse. In this video, you’ll run it as step three of a four-step audit.

00:39 Step one needs no tools. Click the site name, press Tab, and follow the outline. It goes Home, Plots, Volunteers, Events, Work Day, and Seed Swap. Then it jumps back to About, at the front.

00:54 Focus moved backward, because CSS moved the box but not its place in the HTML. Note it, and keep going. In the form, every field gets its outline, and the task group is a single stop.

01:08 Then use each control with its keys, and Shift Tab back up the page.

01:15 Step two checks what a screen reader will be told. Inspect a control, and read the Accessibility pane for its role and name. Email is a textbox named by its label, Email, required.

01:27 Its error message is the description. The Sign up button is a button, named by its own text.

01:34 Do this for every control you tabbed to. Each role and name should match what a visitor sees.

01:42 For step three, open the Lighthouse panel in DevTools. Tick only Accessibility, and click Analyze page load. It reloads the page and runs automated checks on its code and colors, such as labels, names, contrast, and language.

01:58 It scores the page from zero to one hundred. Its contrast check sees only the page as it loads, so check error states and zoom in step one.

02:09 Tomás’s change is still in the page. Your turn: pause the video and predict the score Lighthouse gives it. One hundred. Lighthouse never pressed Tab, so it couldn’t see focus jump backward, and its report admits it.

02:25 Under the score, it lists ten items to check by hand. One is that the visual order follows the DOM order, the order of the HTML.

02:34 So one hundred means every check Lighthouse scores has passed, like a test suite that proves only what it tests. It doesn’t mean every visitor can use the page.

02:44 The same page also scores one hundred with its focus outline removed, or with Sign up turned into a div. Take out Tomás’s rule. If Rosa still wants About first, move its list item to the top in the HTML.

03:00 Step four is a short pass with a real screen reader, VoiceOver on a Mac, or Narrator or NVDA on Windows. This video can’t record one, so here’s what one reads instead.

03:11 It’s Chrome’s full accessibility tree. It has four landmarks. The header is called banner, the nav navigation, and the footer content info. Main keeps its name.

03:23 Inside main, each form field has its role and name.

03:28 The text below gives each reader’s keys for moving by landmark and by field. On your own pass, listen for the same landmarks and names you saw here.

03:39 So an audit is four checks, in this order. The keyboard is free and finds what a visitor can’t reach. The pane shows what’s announced. Lighthouse runs what a machine can measure.

03:51 And a screen reader confirms it by ear.

03:54 The keyboard and the pane come first, so a Lighthouse hundred can’t talk you out of them. It’s one check passed out of four. Run all four on every page of the site.

04:05 In the next exercise, Repair the Seed Swap Form, you’ll make the seed swap page’s form work for every visitor.

Become a Member to join the conversation.