Smooth scroll with a header offset
Anchors stop below a sticky header.
CSS · Smooth scroll with a header offsetIntermediate
html { scroll-behavior: smooth; }
:target, h2[id], h3[id] { scroll-margin-top: 5rem; }
@media (prefers-reduced-motion: reduce) {
html { scroll-behavior: auto; }
}scroll-behaviorscroll-marginanchorsticky header