Walk the Site With the Keyboard

Tomás told Marjorie he can’t find the rehearsal schedule or sign up for the spring concert. He uses a screen reader and, like many people who do, moves through pages with the keyboard. So do people who can’t hold a mouse steadily. A page that doesn’t work with the keyboard fails all of them. You can check it without any tools.

In this lesson, you’ll predict where Tab goes on the choir’s site, walk it to check, and fix a spot where the keyboard gets stuck.

Find What Tab Can Reach

Someone without a mouse still needs to pick a link or a button. At any moment, one element has focus, and that element receives the next keypress. Tab moves focus forward, and Shift+Tab moves it back. Each element it stops on is a tab stop.

Links with an href attribute, buttons, and form fields are tab stops on their own, because people operate them. Headings, paragraphs, images, and plain <div> elements aren’t. Tomás still needs the text, and he reaches it with his screen reader’s own reading keys, which come later in the course. Tab is for controls.

Throughout the course, you’ll use the site as Tomás does, name what fails, fix it, and check again.

Get the course’s code download from the course page, unzip it, and open 01-walk-keyboard/starting-site/index.html with your editor’s Live Preview in Chrome or Edge. The finished site is in the same download, in 20-choir-site-project/finished-site/, for when you want to compare. Keep the starting site open as you work, and make the window wider than about 650 pixels, because the narrow-screen menu waits for a later lesson.

Before you press anything, read index.html and concerts.html in your editor and write down each page’s tab stops in the order you predict. On Concerts, stop at the sign-up link and leave the Ticket prices dialog closed.

When you press Tab, you’ll barely see focus, because the stylesheet’s base layer removes the outline from links and buttons:

Language: CSS
@layer base {
  a,
  button {
    outline: none;
  }
}

The site’s CSS uses cascade layers, role-named custom properties such as --color-focus, and rem sizes. This rule breaks the Web Content Accessibility Guidelines (WCAG) success criterion 2.4.7 Focus Visible, which requires keyboard users to be able to see where focus is. Form fields keep their ring, and the next lesson fixes the rest.

To see focus for now, switch the rule off in DevTools. Every reload brings it back, including the one Live Preview does after each save. So repeat these steps, the walk’s reset, each time:

  1. Open DevTools, select any link in the Elements panel, and clear the checkbox next to outline: none in the Styles pane.
  2. Click an empty spot in the dark header, between the choir’s name and the nav. That moves keyboard focus from DevTools back to the top of the page.
  3. Press Tab. A ring should appear on the choir’s name.

Walk the home page until focus leaves it for the browser’s controls, checking your list. Then open the Concerts page, do the reset, and walk it to the sign-up link.

On the home page:

  1. The choir’s name
  2. Home
  3. Rehearsals
  4. Concerts
  5. Join, in the nav
  6. See the program and dates
  7. Come along to a rehearsal
  8. The newsletter’s Email field
  9. The newsletter’s Join button
  10. The footer’s Instagram link
  11. The footer’s YouTube link

Then focus moves into the browser’s controls and back to the choir’s name. The footer’s icon links are tab stops despite having no text. You’ll name them later.

On Concerts, focus visits the same five header stops, then Ticket prices and the sign-up link. It skips Get tickets, a <div> styled as a button, which the ARIA section fixes.

Did Join surprise you? It’s drawn first in the nav but reached after the other three links. After five presses, the ring sits on the leftmost link:

The choir's dark header with its nav reading Join, Home, Rehearsals, Concerts. The focus ring is on Join, the first link on screen, after five presses of Tab.
Focus Reaches Join Last, Though It's Drawn First

Watch out for order in a flex layout. Here, order: -1 on .nav-join moves only the box, while Tab and screen readers follow the HTML. 2.4.3 Focus Order requires the order to preserve meaning and operation, so that isn’t automatically a failure. Still, a ring jumping back left confuses people. Move the link in the HTML instead.

If a walk didn’t match your list, this button opens the mentor to trace why with you:

Walk Into the Ticket Prices Dialog

Your walk showed the Tab order, the sequence of tab stops, which follows the source. Tab moves between controls, and other keys operate them: Enter follows a link, Space presses a button, and the arrow keys choose an option in a <select>.

2.1.1 Keyboard requires all page functions to work from the keyboard. Users must also be able to leave every part of a page, which the Concerts page’s dialog doesn’t allow.

On Concerts, do the reset, tab to Ticket prices, and press Enter. It opens a modal dialog, a box over the page that puts the rest out of reach while it’s open. The site’s HTML does this with no JavaScript. That’s all you need about dialogs for now. Focus moves to the dialog’s only tab stop, the Getting to the venues link:

The Concerts page dimmed behind a Ticket prices dialog listing adult, student and senior, and under-12 prices, and a focused Getting to the venues link. It has no close button.
The Ticket Prices Dialog With No Way Out

Now try to get back to the page with Tab, Shift+Tab, and Esc. Focus goes from the link to the browser’s controls and back, and Esc does nothing.

That’s a keyboard trap, and it breaks 2.1.2 No Keyboard Trap. If focus can move into part of a page, the keyboard must be able to move it out again.

The dialog’s closedby="none" stops Esc or a click outside from closing it, and there’s no close button. If Tomás opens the prices on his way to the sign-up link, he can’t dismiss them and carry on. He has to follow the venue link away or reload.

Note the trap and its page. In the auditing section, you’ll learn to write it up as a finding.

The trap was checked in Chromium 159 on November 28, 2026. Safari doesn’t support closedby yet, so Esc closes the dialog there. Chrome, Edge, and Firefox keep it open. A Close button works everywhere. Add it inside the <dialog>, after the link’s paragraph:

Language: HTML
<button commandfor="ticket-prices" command="close">Close</button>

The commandfor attribute names the dialog’s id, and command="close" closes it. Save, do the reset, and open the dialog with the keyboard. Tab now moves from the link to Close:

The Ticket prices dialog over the dimmed Concerts page, now with a focused Close button below the Getting to the venues link.
The Dialog With a Close Button

Press Enter on Close. The dialog closes, and focus returns to Ticket prices, so one more Tab reaches the sign-up link. The way out is visible, works from the keyboard, and is in the Tab order.

This button opens the mentor to talk through other ways a page can trap the keyboard:

Add and Remove Tab Stops With tabindex

Sometimes you need to change which elements are tab stops. The tabindex attribute does that, with two values you’ll use:

  • tabindex="0" makes an element a tab stop, in its place in the source.
  • tabindex="-1" makes an element focusable but not a tab stop: Tab skips it, but a link can still send focus to it.

On a control people need, -1 does harm. Suppose the Concerts page’s Rehearsals link had it:

Language: HTML
<li><a href="rehearsals.html" tabindex="-1">Rehearsals</a></li>

In Chromium, Tab then skips from Home to Concerts. A mouse still works. Nobody using Tab reaches Rehearsals, and there’s no other keyboard route, so it fails 2.1.1.

The value -1 suits an element that a link sends focus to but nobody operates. The starting Concerts page has no such link, so this one is only a sketch. Suppose it had a link to its Dates heading:

Language: HTML
<p><a href="#dates">Jump to the dates</a></p>
<h2 id="dates" tabindex="-1">Dates</h2>

Pressing Enter on that link would move focus to the heading, so the next Tab would carry on from the dates, though Tab alone would never stop there. The skip link in a later lesson works this way to jump past repeated navigation. That’s all you need about it for now.

You’ll rarely need tabindex="0", because it’s for JavaScript-built controls, which this course doesn’t build.

Watch out for positive values such as tabindex="1". Such elements come before every other tab stop, lowest value first. The rest follow in source order. Focus jumps around, and later changes break the order.

Check Your Understanding

  1. On the home page, Join is drawn first in the nav but gets focus after the other links. Why, and how would you make the orders match?
  2. The Ticket prices dialog still let Tab move focus. Why was it a keyboard trap?
  3. In the sketch, the Dates heading has tabindex="-1". Is it focusable, is it a tab stop, and what sends focus to it?
  1. order: -1 moves only Join’s box, but Tab follows the HTML, where Join is last. Move its list item first in the HTML and drop order: -1.
  2. Focus could only go between the dialog’s link and the browser’s controls. Nothing on the keyboard closed the dialog, so it failed 2.1.2.
  3. It’s focusable but not a tab stop: Tab skips it. The Jump to the dates link sends focus to it.

You’ve walked two pages and freed the Ticket prices dialog, but you only saw focus by switching a rule off. In the next lesson, Keep Focus Visible and in View, you’ll give the site a lasting focus style that the sticky header can’t hide.

Become a Member to join the conversation.