# scroll-snap-type

> The `scroll-snap-type` CSS property sets how strictly a scroll container snaps to snap points.

## How do I build a CSS scroll snap carousel?

The property of a scroll container that enables scroll snapping on the 'x', 'y' or 'both' axes. The 'mandatory' value always snaps to a point, while 'proximity' snaps only when close. Used for carousels and slides without JS.

- Topic: Client Interface
- Type: property
- Browser support: Chrome 69+, Chrome Android 69+, Edge 79+, Firefox 99+, Firefox Android 39+, Safari 11+, Safari iOS 11+

## Example

Wrong:

```css
.carousel {
  display: flex;
  scroll-snap-type: x mandatory;
}
```

Right:

```css
.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.carousel > * {
  scroll-snap-align: start;
}
```

Snapping needs a scroll container and snap positions on the children; without `overflow` and `scroll-snap-align` nothing snaps.

## Common mistakes

- Content taller than the screen can't be read because 'mandatory' snaps past it.

## Key points

- 'mandatory' is used only when every item fits the viewport; tall content uses 'proximity'.
- The container has `overflow` set to 'auto' or 'scroll' on the snapping axis.
- Snapping is done with CSS, not a JavaScript snapping library.

## Interview questions

### What is the difference between mandatory and proximity?

'mandatory' always snaps to a snap point when scrolling stops. 'proximity' snaps only when the scroll ends close to one.

### How do I stop users from skipping several slides in one swipe?

Set `scroll-snap-stop: always` on the items, so scrolling stops at each snap point.

### Does scroll snap work with the keyboard?

Yes. Arrow keys and page keys scroll the container, and the browser snaps to the nearest snap point.

## Related cards

- [scroll-snap-align](https://wonderium.dev/css/scroll-snap-align.md)
- [scroll-padding](https://wonderium.dev/css/scroll-padding.md)
- [overflow](https://wonderium.dev/css/overflow.md)
- [scroll-behavior](https://wonderium.dev/css/scroll-behavior.md)
- [scrollbar-width](https://wonderium.dev/css/scrollbar-width.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/scroll-snap-type
- Last updated: 2026-11-25
