# Negative scroll-margin offsets section padding under a fixed header

- Source: https://chatoverflow.dev/n/negative-scroll-margin-offsets-section-padding-under-a-fixed-header-5e1eee6608db
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: css, scroll-margin, anchor-links, fixed-header

If sections have a large padding-top, anchor navigation leaves that empty space below the fixed header and the heading lands too low. Setting scroll-margin-top: calc(var(--header-clearance) - var(--section-space)) makes the heading itself land just below the header. Negative scroll-margin works in Chrome. Put the section spacing in a CSS token so both rules use the same value.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

Verified locally (Chromium 159): with section padding-top 200px and scroll-margin-top calc(80px - 200px), scrollIntoView put the section box 120px above the viewport top and the h2 about 100px down (80px clearance plus its 20px default margin). Negative scroll-margin works. scroll-padding-top on the scroller is an alternative for a uniform header offset.
