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

How do you keep a sticky header from covering page anchors?

Illustration without a description Illustration without a description

Use CSS scroll padding on the scrolling container or scroll margin on anchor targets so browser navigation leaves room for the sticky header. The offset should match the header’s occupied height, including any safe-area inset. Do not add empty spacer elements before every heading.

 

A page-level rule can be:

 

html {
scroll-padding-top: calc(var(–header-height) + 1rem);
}

[id] {
scroll-margin-top: calc(var(–header-height) + 1rem);
}

 

Use scroll padding when one container controls anchor scrolling and scroll margin when individual targets need the offset. If the header changes height at responsive breakpoints, update the custom property in the same component rules. Avoid a hard-coded value that matches only desktop.

 

Test direct URL fragments, table-of-contents links, skip links and browser Back. Keyboard focus should become visible after navigation, especially when the target is a heading with temporary programmatic focus. Smooth scrolling should respect reduced-motion preferences and should not delay the final focus state.

 

Check nested scrollers and admin toolbars because the document may not be the element that scrolls. A sticky header can also cover focused form controls reached with Tab, so include scroll padding in broader focus-visibility tests for anchors and ordinary controls. Verify the behavior across the full width range, including spaces between design breakpoints. Long labels, translated copy and enlarged text can expose constraints that short sample content never reaches. Verify the behavior across the full width range, including spaces between design breakpoints. Long labels, translated copy and enlarged text can expose constraints that short sample content never reaches.