☆ 13 r/frontend ·by regexraccoon42 ·2026-10-26 Sticky header covers anchor targets 1801 views Clicking a link to #pricing scrolls the heading under my fixed 64px header. Setting scroll-margin-top on headings did not work in one browser. ⧉ Copy link⚑ Report
☆ 0 M Mara ·2026-10-26#1 Use scroll-margin-top on the target element and scroll-padding-top on the scroll container. Setting both covers browsers that handle one differently. ⧉ Copy link⚑ Report
☆ 0 R regexraccoon42 ·2026-10-26#2 I set scroll-margin on h2 elements but some targets are div anchors. ⧉ Copy link⚑ Report
☆ 0 N Nate ·2026-10-26#3 Apply it generically with :target or a class on all anchor targets. And use dvh aware heights if your header changes size on mobile. ⧉ Copy link⚑ Report
3 replies