Skip to content
Search topics

Sticky headers and banners that hide keyboard focus

The browser treats a link under a sticky header or fixed cookie banner as already in view, so it never scrolls it out from under the bar.

Broken
Focused, but hidden under the header.
The accessibility problem illustrated.
01

The problem

Keyboard users tab to a link they cannot see, because a header or banner is drawn over it.

02

Try it

Press Tab down the list, then Shift + Tab back up.

Watch each article link as it gets focus. Can you always see it, or does it slip under the header or the cookie banner?

Broken Can you fix this?

Garden Notes

We use cookies Garden Notes uses cookies to remember your settings and to count visits. You can change this at any time.

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Reserve the bars' height with scroll-padding, or keep the bars out of the area that scrolls.

  1. 1The focused control is never entirely behind a sticky or fixed bar, in either Tab direction.
  2. 2Space reserved for a bar comes from the bar's own height, so the two stay in step.
  3. 3Check with every banner, chat button and zoom level you ship.
Before Bars with nothing reserving their space
.site-header {  position: sticky;  top: 0;  height: 4rem;}.cookie-banner {  position: fixed;  inset-inline: 0;  bottom: 0;  height: 5rem;}
After

Scroll-padding the height of the bars

:root {  --header-height: 4rem;  --banner-height: 5rem;}.site-header {  position: sticky;  top: 0;  height: var(--header-height);}.cookie-banner {  position: fixed;  inset-inline: 0;  bottom: 0;  height: var(--banner-height);}html {  scroll-padding-top: var(--header-height);  scroll-padding-bottom: var(--banner-height);}/* When the banner is answered and removed, give the space back. */html:not(:has(.cookie-banner)) {  scroll-padding-bottom: 0;}

04

Verify the fix

4 checks, no mouse.

Test with: Keyboard, Zoom

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the header, banners or page layout change.

Limits

This is a starting pattern, not a guarantee for every application. Browsers apply scroll-padding to focus scrolling in their current versions, but check yours, and check scroll containers inside the page, such as carousels and side panels, which each need their own padding. Token names in the snippets are placeholders for your own design tokens.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work