Create sticky headers and scroll-margin offsets that never hide anchors

8 steps · about 1 h 12 min · Beginner

  1. 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.

  2. 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.

  3. 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.

  4. MDN: scroll-margin-top (reference, MDN Web Docs, 8 min)

    Shows how scroll-margin-top on headings reserves breathing room above anchored targets.

  5. 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.

  6. 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.

  7. MDN: scroll-behavior (reference, MDN Web Docs, 8 min)

    Covers smooth scrolling for anchor jumps and how to guard it behind prefers-reduced-motion.

  8. MDN: scroll-margin (reference, MDN Web Docs, 8 min)

    Documents the shorthand properties for horizontal and vertical scroll snap and anchor offsets.