Sub topic 17
Testing navigation and footers
This chapter assumes you can write semantic HTML and CSS, and that you have built a primary navigation, a mega menu, and a footer like the ones in earlier chapters. Here you check that they work for keyboard, screen reader, and touch users.
Why test by hand
Automated checkers catch missing labels and low contrast. They cannot tell you whether the focus order makes sense, whether Escape returns focus to the right place, or whether a link name is clear when read aloud. Plan a short manual pass for every navigation change.
Keyboard test
Put the mouse away and use only the keyboard. Reload the page and press Tab from the top.
- The first stop is the skip link, and it becomes visible.
- Press Enter on the skip link. Focus moves to
main, and the next Tab lands on the first link inside the content. - Tab through every navigation item in reading order. Each focused item shows a clear outline.
- On a mega menu button, press Enter or Space. The panel opens, and
aria-expandedchanges totrue. - Tab into the panel and through its links. Press Escape. The panel closes and focus returns to the button.
- Tab to the footer. Every footer link is reachable and visible when focused.
Screen reader test
Use one screen reader that is common on your platform, such as NVDA on Windows or VoiceOver on macOS. Open the landmarks list and check the following.
- Primary navigation is announced as "Primary navigation" and footer navigation as "Footer navigation". Two unnamed navigation landmarks are indistinguishable.
- The current page link is announced as current.
- The mega menu button is announced with its name and state, such as "Products, button, collapsed".
- Link text makes sense out of context. Open the links list and look for repeats like "Read more".
Touch and small screen test
Open the page on a real phone, or at 320 px width in browser developer tools. Check that:
- Targets are at least 44 by 44 CSS pixels, or have enough spacing around them.
- The menu opens with a tap and does not depend on hover.
- Text can be zoomed to 200% without the navigation overlapping content.
Quick automated checks
You can add a small script for checks that are cheap to repeat. This one runs in the browser console and reports navigation landmarks without a name and buttons with a missing state.
const unnamedNavs = [...document.querySelectorAll('nav')].filter(
(nav) => !nav.getAttribute('aria-label') && !nav.getAttribute('aria-labelledby')
);
const stateless = [...document.querySelectorAll('button[aria-controls]')].filter(
(button) => !button.hasAttribute('aria-expanded')
);
console.log('Unnamed nav landmarks:', unnamedNavs.length);
console.log('Disclosure buttons without aria-expanded:', stateless.length);Both counts should be zero. A tool such as axe DevTools or Lighthouse adds contrast and ARIA validity checks.
Common errors
| Symptom | Likely cause |
|---|---|
| Skip link never appears | The `:focus` rule is missing or the link is hidden with `display: none` |
| Focus outline missing | `outline: none` set without a replacement |
| Escape closes the panel but focus is lost | The handler does not call `button.focus()` |
| Screen reader says "navigation" twice with no names | Missing `aria-label` on one of the `nav` elements |
Exercise
You open a mega menu with the keyboard, press Escape, and the panel closes, but the next Tab starts again from the top of the page. What is wrong, and how do you fix it?
Show answer
Focus was not returned to the trigger button, so the browser lost its position when the focused panel link was hidden. In the Escape handler, call button.focus() after setting aria-expanded to false and hiding the panel.