scroll-margin
Widely availableSince 202197% of users
Defines the margin (offset) of an element when it is scrolled into view via scroll-snapping or anchor links. This is extremely useful for preventing fixed headers from covering the top of a section.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyModernIn every major browser since July 2021. Widely available since January 2024.
See how modern your own CSS is.Check your CSS →
Quick facts
- Initial value
See individual properties- Inherited
- No
- Applies to
- all elements
- Animation type
- byComputedValueType
Quick example
section {
scroll-margin-top: 100px;
/* prevents a fixed header from overlapping the section when navigating via ID links */
}Related snippet
Anchor offsets without JavaScript scroll mathLayout →scroll-margin browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2021.Safe to use without fallbacks.
Usage97%of people can use this3% use a browser without it.
Browsers
69+
90+
14.1+
79+Mobile
69+Android
90+Android
14.5+iOS
Interop 2026 focus area. All major browsers are actively working to fix cross-browser inconsistencies for this feature in 2026. Learn more →