CSS Scroll Snap Reference

scroll-snap-type, scroll-snap-align, scroll-margin properties with container/item split.

Reference for the CSS Scroll Snap module: container properties (scroll-snap-type, scroll-padding), item properties (scroll-snap-align, scroll-snap-stop, scroll-margin) and mandatory vs proximity behaviour.

What is the difference between mandatory and proximity?

scroll-snap-type: x mandatory forces the scroll to always rest on a snap point — you cannot stop between items. proximity only snaps when you release the scroll near a snap point, otherwise it stays put. Mandatory is ideal for full-screen carousels; proximity for long lists where free scrolling matters.

What CSS Scroll Snap does

Scroll Snap lets a scroll container rest on defined snap points instead of stopping anywhere. It powers carousels, paginated galleries and full-screen sections with no JavaScript. The properties split cleanly: a few go on the scroll container to define the axis and strictness, and the rest go on each scrollable item to define where it aligns. This reference lists them all with their accepted values.

How it works

The container declares an axis and strictness with scroll-snap-type; each child declares where it rests with scroll-snap-align:

.carousel {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 1rem;
}
.carousel > .slide {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  scroll-margin-left: 0.5rem;
}

mandatory guarantees the scroll always lands on a slide; proximity only snaps when you release near one. scroll-snap-align: start aligns each slide’s left edge to the (padded) container edge. scroll-snap-stop: always blocks a single fling from skipping past slides.

Tips and notes

  • A snap container must actually scroll — set overflow and a constrained size, or nothing snaps.
  • Combine scroll-padding (container) with scroll-margin (item) to clear a sticky header.
  • Use logical-axis values block/inline for writing-mode-aware snapping.
  • scroll-snap-align: none opts a single item out of snapping inside a snapping container.