scroll-margin

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.

Quick example

section {
  scroll-margin-top: 100px;
  /* prevents a fixed header from overlapping the section when navigating via ID links */
}

Quick facts

Initial value
See individual properties
Inherited
No
Applies to
all elements
Animation type
byComputedValueType

scroll-margin Browser Support

Widely available Since 2020 95% global usage

This feature is well established and works across many devices and browser versions. It has been available across browsers since 2020.

Safe to use without fallbacks.

69+
90+
14.1+
79+
ESC