Create sticky headers and scroll-margin offsets that never hide anchors
8 steps · about 1 h 12 min · Beginner
- MDN: position (reference, MDN Web Docs, 12 min)
Contrasts position: sticky with fixed and relative positioning, including how sticky elements stay inside their parent box.
- MDN: overflow (reference, MDN Web Docs, 10 min)
Explains why overflow: hidden on an ancestor silently breaks position: sticky and how overflow: clip avoids it.
- Fixed Headers, On-Page Links, and Overlapping Content (article, CSS-Tricks, 12 min)
Visualizes the classic bug where jumping to a #section-id lands with the heading hidden behind a sticky header.
- MDN: scroll-margin-top (reference, MDN Web Docs, 8 min)
Shows how scroll-margin-top on headings reserves breathing room above anchored targets.
- MDN: scroll-padding-top (reference, MDN Web Docs, 8 min)
Shows how setting scroll-padding-top on html protects every anchor and keyboard focus scroll at once.
- Prevent anchor links from scrolling behind a sticky header (article, Go Make Things, 6 min)
Gives a concise pattern combining scroll-padding-top with a CSS custom property for header height.
- MDN: scroll-behavior (reference, MDN Web Docs, 8 min)
Covers smooth scrolling for anchor jumps and how to guard it behind prefers-reduced-motion.
- MDN: scroll-margin (reference, MDN Web Docs, 8 min)
Documents the shorthand properties for horizontal and vertical scroll snap and anchor offsets.