scroll-padding

Sets the padding (inner offset) of a scroll container. It ensures that when elements snap or are scrolled into view, they stay a certain distance away from the edges of the container.

It is documented as part of the CSS Scroll Snap specification.

/* Usage Example */
html {
  scroll-padding-top: 4rem;
  scroll-behavior: smooth;
  /* ensures all anchor-link navigations stop 4rem before the target element */
}

/* Syntax */
scroll-padding: auto;

/* Global values */
scroll-padding: inherit;
scroll-padding: initial;
scroll-padding: revert;
scroll-padding: revert-layer;
scroll-padding: unset;
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+
14.1+
79+
Kinsta

Your first month is free

Managed WordPress hosting for faster sites.

Learn more

New CSS drops.

Join 600+ readers who've survived clearfix hacks.

ESC