scroll-margin-block
A shorthand that sets both the start and end scroll margins at the same time. It creates a 'snap buffer' in the vertical direction (or whatever the 'block' axis is).
It is documented as part of the CSS Scroll Snap specification.
Syntax
/* Usage Example */
h2 {
/* Adds a 2rem buffer on both the top and bottom when snapping to this header */
scroll-margin-block: 2rem;
}
/* Global values */
scroll-margin-block: inherit;
scroll-margin-block: initial;
scroll-margin-block: revert;
scroll-margin-block: revert-layer;
scroll-margin-block: unset;
scroll-margin-block 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.
69+
68+
15+
79+