Explore Bato Web Agency Webflow Certified Partner Profile Explore Bato Web Agency Webflow Certified Partner Profile

How do you prevent a sticky header from hiding the focused element?

Illustration without a description Illustration without a description

A sticky header can cover controls when the browser scrolls them into view during keyboard navigation or anchor movement. WCAG 2.2 Level AA requires an author-created layer not to hide a focused component completely. The stronger Level AAA requirement prevents any part of the focused component from being obscured.

 

Reserve scroll space that matches the header rather than adding one-off margins to individual controls. The CSS scroll-padding-top property can offset scrolling for a container, while scroll-margin-top can protect specific targets such as headings and form fields. Account for header height changes at responsive breakpoints.

 

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

:target,
button,
input,
select,
textarea {
scroll-margin-top: 5rem;
}

 

Offset alone may not solve every case. Cookie banners, chat windows and sticky footers can cover content from other directions. Make persistent overlays dismissible, constrain their size or treat a blocking interaction as a genuine modal with background content inactive. Ensure scripts that call scrollIntoView() respect the same layout.

 

Tab through the entire page at normal size, high zoom and narrow widths, watching the focused component rather than only its outline. Test anchor links, validation focus and dynamically inserted content. Store header dimensions in shared CSS custom properties so offsets stay aligned with design changes. If the header expands after loading, recalculate or design the layout so content begins below it rather than relying on a stale fixed value. Confirm that focus indicators outside the component boundary remain visible too. The robust fix creates a consistent safe viewport area so every focus movement remains visible without component-specific patches.