# Test keyboard navigation

- Check 11.08 · Semantic HTML and accessibility · Important
- Source: https://checklist-seo-geo.com/en/semantic-html-accessibility/test-keyboard-navigation
- Go through your pages with the keyboard using a test grid, then fix invisible focus, illogical order, keyboard traps and inaccessible menus.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/semantic-html-accessibility/test-keyboard-navigation.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

Testing keyboard navigation means going through a page without a mouse, using `Tab`, `Shift + Tab`, `Enter`, `Space`, the arrow keys and `Esc`, and checking that you can reach everything, see everything and use everything. The check consists of running this test on the main templates and user journeys (home, listing, product page, form, cart), logging the issues in a grid, then fixing them. Expected result: a keyboard user always sees where they are, follows a logical order, opens menus and dialogs, and is never stuck.

## Why it matters

Many people browse without a mouse: blind people using a screen reader, people with motor disabilities who use a keyboard, a switch or voice control, power users who prefer the keyboard. All these aids rely on the same mechanisms as the `Tab` key: if a menu only opens on hover, if a consent dialog holds on to focus, if focus is invisible, part of the site is closed to them.

The keyboard test also reveals construction flaws that affect crawlers and AI agents. An element reachable with the keyboard is almost always a real link, a real button or a real field; an element that cannot be reached is often a clickable `<div>`, which a crawler does not follow and a browsing agent struggles to identify. Agents that drive a browser on a user's behalf do not publish how they work in detail, but a site usable with the keyboard offers explicit, predictable controls, which makes their job easier.

Finally, the test is required by the standards: WCAG 2.1.1 (everything is operable with the keyboard), 2.1.2 (no keyboard trap), 2.4.3 (focus order), 2.4.7 (focus visible) and 2.4.11 (focus not obscured, added in WCAG 2.2), and in France RGAA (the French accessibility framework) criteria 7.3, 10.7, 12.7, 12.8 and 12.9.

## What it improves

- **Accessibility**: full access for people who cannot use a mouse.
- **Conversion**: forms, filters and carts usable by everyone; keyboard blockers are often outright blockers on some devices.
- **Code quality**: the test surfaces fake links and fake buttons, which are just as problematic for crawling.
- **AI agents**: reachable, identifiable controls. A plausible effect, poorly documented.
- **Ranking**: no direct effect.

## How to check

### Set up your machine

- **Windows and Linux**: nothing to configure. Chrome, Edge and Firefox move through links, buttons and fields with `Tab`.
- **macOS**: turn on `System Settings > Keyboard > Keyboard navigation`. In Safari, also turn on, in the Advanced settings, the option that lets the Tab key highlight each item on a webpage; without it, `Tab` skips links (`Option + Tab` reaches them).
- **Visual aids**: in Firefox, the Accessibility Inspector offers a “Show Tabbing Order” checkbox, which numbers the tab stops on the page. Accessibility Insights for Web offers an equivalent visualization (“Tab stops”).

To find out where focus is when it is invisible, paste this into the developer tools console:

```js
document.addEventListener('focusin', () => {
  const el = document.activeElement;
  console.log(el.tagName.toLowerCase(), el.getAttribute('aria-label') || el.textContent.trim().slice(0, 40), el);
});
```

### Run the test

Start from the address bar, then:

1. **First `Tab`**: a “Skip to content” link should appear; `Enter` moves focus to the start of the main content.
2. **`Tab` to the end of the page**, then `Shift + Tab` to go back: every interactive element is reached, in visual order, with a visible focus indicator that is not hidden by a sticky header or a banner.
3. **Menus**: a submenu opens with `Enter` or `Space` on its button, can be navigated, and closes with `Esc`.
4. **Modal dialogs and consent banner**: focus moves into the dialog when it opens, stays there while it is open, `Esc` closes it, and focus returns to the element that opened it.
5. **Rich components**: carousel (pause, next, previous), tabs, accordions, price sliders, date pickers, interactive maps.
6. **Forms**: every field is reached, checkboxes and radio buttons are checked with `Space`, lists are operated with the arrow keys, submission works with `Enter`, and focus moves to the first error message.
7. **Full journey**: adding to cart and starting checkout, booking an appointment, internal search.

### The deliverable: the test grid

| Page | Step | Criterion | Expected result | Finding | Severity | Fix |
| --- | --- | --- | --- | --- | --- | --- |
| Home | 1st `Tab` | Skip link | visible, leads to the content | missing | medium | add to the layout |
| Home | “Products” menu | Submenu | opens with `Enter`, closes with `Esc` | opens only on hover | blocking | `aria-expanded` button |
| Product page | size selector | Visible focus | clear outline | no outline | blocking | global `:focus-visible` |
| Product page | “Add to cart” | Order | after the size | reached before the price | low | fix the DOM order |
| All | cookie banner | Trap | `Esc` or a button closes it, focus restored | focus stuck behind the banner | blocking | modal `<dialog>` |
| Contact | submission with an error | Focus management | focus on the first error | focus stays on the button | medium | move focus |

Classify as “blocking” anything that prevents completing a task: fix these first.

## How to implement

### Before you start

Most fixes come down to five rules that apply everywhere.

**1. Never remove the focus indicator without replacing it.** Give it a clear style, with a contrast of at least 3:1 against the background:

```css
:focus-visible {
  outline: 3px solid #005fcc;
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

html {
  scroll-padding-top: 5rem;
}
```

`scroll-padding-top` prevents the targeted element from ending up under a sticky header.

**2. Use native elements.** `<a href>`, `<button>`, `<input>`, `<select>` and `<details>` can be reached and activated with the keyboard without any code. See [distinguish action buttons from navigation links](https://checklist-seo-geo.com/en/semantic-html-accessibility/distinguish-action-buttons-from-navigation-links).

**3. Let the tab order follow the DOM.** Never use a `tabindex` greater than 0. `tabindex="0"` makes a non-focusable element focusable (avoid it, prefer a native element); `tabindex="-1"` lets a script move focus to a heading or a container. If the visual order differs from the tab order, fix the HTML rather than the CSS: see [check DOM reading order](https://checklist-seo-geo.com/en/semantic-html-accessibility/check-dom-reading-order).

**4. Open menus with a button, not on hover:**

```html
<nav aria-label="Main menu">
  <ul>
    <li>
      <button type="button" aria-expanded="false" aria-controls="sous-menu-produits">Products</button>
      <ul id="sous-menu-produits" hidden>
        <li><a href="/chaises">Chairs</a></li>
        <li><a href="/tables">Tables</a></li>
      </ul>
    </li>
  </ul>
</nav>
```

```js
document.querySelectorAll('nav button[aria-controls]').forEach((bouton) => {
  const sousMenu = document.getElementById(bouton.getAttribute('aria-controls'));

  bouton.addEventListener('click', () => {
    const ouvert = bouton.getAttribute('aria-expanded') === 'true';
    bouton.setAttribute('aria-expanded', String(!ouvert));
    sousMenu.hidden = ouvert;
  });

  bouton.parentElement.addEventListener('keydown', (event) => {
    if (event.key !== 'Escape') {
      return;
    }

    bouton.setAttribute('aria-expanded', 'false');
    sousMenu.hidden = true;
    bouton.focus();
  });
});
```

**5. Use `<dialog>` for modal dialogs.** Opened with `showModal()`, it makes the rest of the page inert, closes with `Esc`, and recent browsers return focus to the triggering element when it closes:

```html
<button type="button" id="ouvrir-guide">Size guide</button>

<dialog id="guide-tailles" aria-labelledby="titre-guide">
  <h2 id="titre-guide">Size guide</h2>
  <p>…</p>
  <form method="dialog">
    <button>Close</button>
  </form>
</dialog>

<script>
  document.getElementById('ouvrir-guide').addEventListener('click', () => {
    document.getElementById('guide-tailles').showModal();
  });
</script>
```

For a non-modal side panel, the `inert` attribute on the rest of the page prevents focus from wandering there.

> **Warning:** consent banners, chat widgets and booking plugins are the leading source of keyboard traps, and you do not control their code. Test them first and, if the vendor does not fix them, switch tools.

### WordPress

Versions: WordPress 6.4 and later.

- **Theme**: look for `outline: none` or `outline: 0` in the theme's and plugins' stylesheets, and add the `:focus-visible` rule in the child theme or, for a block theme, in `Appearance > Editor > Styles`, ⋮ menu at the top of the panel, “Additional CSS” (`Appearance > Customize > Additional CSS` for a classic theme).
- **Navigation block**: it handles opening submenus on click and with the keyboard; in its settings, choose opening on click rather than on hover, and keep the mobile menu button.
- **Skip link**: recent block themes add it automatically when the template contains a `<main>` group; for a classic theme, add it in `header.php`.
- **Plugins**: sliders, pop-ups, forms and consent banners need to be tested one by one. Prefer those that document their accessibility.

### Shopify

Versions: Online Store 2.0 themes (Horizon, Dawn), all Shopify plans, November 2026.

Recent themes, including Dawn, include a skip link, submenus built with `<details>` that open with the keyboard, and keyboard-managed dialogs. Problems mostly come from installed apps (reviews, loyalty, promotional pop-ups, chat) and custom sections. For your own sections, apply the rules above in `assets/`; for an app that traps focus, contact its developer or uninstall it (`Settings > Apps and sales channels`).

### Wix

Versions: Wix Editor and Wix Studio, November 2026.

Wix adds a skip link and manages focus on its native elements. The site's accessibility settings let you show a visible focus indicator: check that it is turned on. Test custom elements and Velo code first, as they do not benefit from these automatic features.

### Squarespace

Versions: Squarespace 7.1, November 2026.

Recent templates handle focus and menus with the keyboard. If you have added custom CSS, check that it does not remove the focus indicator (`Website > Website Tools > Custom CSS`), and test code blocks and third-party embeds.

### Webflow

Versions: Webflow Designer, November 2026.

In the `Style` panel, the “Focused (keyboard)” state corresponds to `:focus-visible`: style it on your link, button and field classes. The Navbar component and its dropdowns are keyboard operable; interactions triggered on hover (`Mouse hover`) on Div Blocks are not: replace them with click triggers on focusable elements.

### Laravel

Versions: Laravel 11 to 13, Livewire 3 and 4.

Put the skip link and the `:focus-visible` rule in the shared layout. After a form is submitted with errors, move focus to the error summary or the first field in error:

```php
@if($errors->any())
    <div id="erreurs" tabindex="-1" role="alert">
        <p>{{ __('The form contains :count error(s).', ['count' => $errors->count()]) }}</p>
    </div>
    <script>document.getElementById('erreurs').focus();</script>
@endif
```

With Livewire, `wire:navigate` replaces the page without a reload: check where focus is after each navigation and move it back to the main heading if needed.

### Next.js

Versions: Next.js 15 and 16 (App Router).

Next.js announces page changes to screen readers, but does not move focus after client-side navigation: focus stays on the clicked link. Test this behavior and, if needed, move focus to the main heading of the new page:

```tsx
'use client';

import { useEffect, useRef } from 'react';
import { usePathname } from 'next/navigation';

export function TitrePrincipal({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLHeadingElement>(null);
  const pathname = usePathname();

  useEffect(() => {
    ref.current?.focus();
  }, [pathname]);

  return <h1 ref={ref} tabIndex={-1}>{children}</h1>;
}
```

For rich components (menus, tabs, drop-down lists), prefer an accessible component library that implements the keyboard patterns of the ARIA Authoring Practices rather than coding them by hand.

### Nuxt

Versions: Nuxt 3 and 4.

The same care as with Next.js regarding focus after navigation. Accessible UI modules and libraries handle menus, dialogs and tabs with the keyboard; for your own components, apply the five rules above.

## Common mistakes

- **A global `outline: none`** in a CSS reset, with no replacement style.
- **Positive `tabindex` values** (`tabindex="1"`, `"2"`…): the order becomes unpredictable as soon as an element is added.
- **Hidden but focusable elements**: a closed mobile menu or an off-screen carousel whose links remain reachable; use `hidden`, `display: none` or `inert`.
- **Menus that open only on hover**: inaccessible with the keyboard and unreliable on touch screens.
- **A modal dialog with no focus management**: focus stays behind the dialog, or escapes to the page.
- **Testing only with the mouse and then running an automated audit**: no tool replaces the manual walkthrough; they detect missing names, not traps or illogical order.

## Frequently asked questions

### How do I test keyboard navigation on a Mac?

First turn on keyboard navigation in System Settings, under Keyboard. In Safari, also turn on, in the Advanced settings, the option that lets the Tab key highlight each item on a webpage; without it, Tab skips links, and Option + Tab reaches them. Chrome and Firefox on Mac behave much like on Windows once keyboard navigation is turned on.

### Is a Lighthouse audit enough to validate keyboard accessibility?

No. Lighthouse, axe or WAVE detect structural problems, such as a button with no name or a positive tabindex, but they cannot tell whether a menu opens with the keyboard, whether a dialog traps focus or whether the tab order is logical. Only a manual walkthrough with Tab, Shift + Tab, Enter, Space, the arrow keys and Esc can do that. Allow about fifteen minutes per template.

### Can I remove the focus outline for aesthetic reasons?

You can replace the default focus outline, not remove it. Use the focus-visible pseudo-class: the style then only shows during keyboard navigation, not on mouse clicks, which settles most aesthetic objections. The indicator must remain clearly visible, with a contrast of at least 3:1, and must not be hidden by a sticky header or a banner.

### Is keyboard navigation related to SEO or AI agents?

Indirectly. Elements that cannot be reached with the keyboard are often clickable divs or links without href, which crawlers do not follow either. Fixing keyboard access therefore often means fixing crawling. For AI agents that browse on a user's behalf, native links, buttons and fields are easier to identify, even though exactly how they work is not publicly documented.

## Resources

- [W3C: Understanding Success Criterion 2.1.1, Keyboard](https://www.w3.org/WAI/WCAG22/Understanding/keyboard.html)
- [W3C: Understanding Success Criterion 2.1.2, No Keyboard Trap](https://www.w3.org/WAI/WCAG22/Understanding/no-keyboard-trap.html)
- [W3C: Understanding Success Criterion 2.4.7, Focus Visible](https://www.w3.org/WAI/WCAG22/Understanding/focus-visible.html)
- [W3C: Understanding Success Criterion 2.4.11, Focus Not Obscured (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-minimum.html)
- [WebAIM: keyboard accessibility](https://webaim.org/techniques/keyboard/)
- [MDN: the dialog element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog)
- [MDN: the inert attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/inert)
- [Firefox: Accessibility Inspector and tabbing order](https://firefox-source-docs.mozilla.org/devtools-user/accessibility_inspector/)

Next steps: [check form labels](https://checklist-seo-geo.com/en/semantic-html-accessibility/check-form-labels), [check DOM reading order](https://checklist-seo-geo.com/en/semantic-html-accessibility/check-dom-reading-order) and [test user journeys with browsing agents](https://checklist-seo-geo.com/en/ai-agent-compatibility/test-user-journeys-browsing-agents).
