Skip to content

Keyboard focus is invisible or hidden

When someone moves through the page with Tab, the element they’re on should be clearly marked. On this page the focus outline has been removed, or a sticky header or banner covers the element that has focus.

Why it matters

Keyboard users need to see where they are. If focus is invisible, they’re typing blind.

A sticky header or cookie banner can cover the element that has focus, with the same result. WCAG 2.2 added a criterion for exactly this.

How to fix it

  1. Never remove the focus outline without a replacement. Add a clear style for :focus-visible, in a colour with 3:1 contrast against the background:
    :focus-visible {
      outline: 2px solid #1a5fb4;
      outline-offset: 2px;
    }
  2. Remove outline: none or outline: 0 rules that aren’t replaced by another visible style.
  3. Add scroll-padding-top equal to the sticky header’s height, so focused elements scroll out from under it:
    html {
      scroll-padding-top: 5rem;
    }
  4. Keep cookie banners and chat buttons from covering content that has focus.

Common mistakes

  • outline: none in a reset stylesheet with nothing in its place.
  • A focus style so faint (a slight colour change) that it can’t be seen.

Check your fix

Once the change is live, check the page again.