# CSS Scroll Snap vs Dynamic Viewport Units (dvh, svh, lvh)

- **Canonical URL:** https://frontend.rocks/vs/css-scroll-snap-vs-dynamic-viewport-units/
- **Relation:** Contrasts With
- **Last Verified:** 2026-11-15
- **Verdict:** Scroll snap aligns scrollport rest positions, whereas dynamic viewport units resize snapports as mobile toolbars animate.

## Comparison Matrix

| Dimension | CSS Scroll Snap | Dynamic Viewport Units (dvh, svh, lvh) |
| :--- | :--- | :--- |
| **Maturity** | Baseline · Widely | Baseline · Widely |
| **Domain** | CSS & Layout | CSS & Layout |
| **Mental Model** | scroll-snap-type and scroll-snap-align lock scroll rest positions to child landmarks on the Compositor Thread without JS timers. | svh, lvh, and dvh disambiguate mobile browser toolbars so full-screen layouts never clip behind the address bar. |
| **Prerequisites** | Render Tree & Layout (Scroll snap positions derive from laid-out child snap-area boxes and scroll-padding.) | Render Tree & Layout (Viewport units resolve during Layout against the small, large, or dynamic viewport box.) |
| **When Not to Use** | When not to use scroll-snap-type: y mandatory: Never apply mandatory vertical snapping to long-form articles or variable-height pages; use proximity or omit it. | When not to use dvh: Avoid dvh on scrollable marketing sections or elements holding heavy text; use svh so line wraps never jump mid-scroll. |

## CSS Scroll Snap — Under the Hood
A JS carousel hijacks the wheel and fights momentum; CSS Scroll Snap lets the native physics engine predict where a fling will land and gently magnetizes it to the nearest snap line.

1. **Snap Area Registration**: During [Render Tree & Layout](/concepts/render-tree-layout), each child's `scroll-snap-align` (`start`, `center`, `end`) registers a target coordinate.
2. **Strictness**: `mandatory` always snaps to a target after scrolling stops; `proximity` snaps only when the rest point lands near a target.
3. **Padding Offset**: `scroll-padding-inline` insets the snapport so sticky headers or peek gutters never overlap the snapped card.

```css
.carousel {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 1rem;
}
.carousel > .slide {
  flex: 0 0 85%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
```

Works seamlessly with [Dynamic Viewport Units](/concepts/dynamic-viewport-units) and [CSS Logical Properties](/concepts/css-logical-properties).

## Dynamic Viewport Units (dvh, svh, lvh) — Under the Hood
Mobile browsers have a telescoping frame: the address bar and bottom tab bar slide in and out during scroll, changing the visible height without changing device dimensions.

1. **`svh` (Small)**: Assumes all browser toolbars are expanded. Zero layout shifts during scroll.
2. **`lvh` (Large)**: Assumes all toolbars are retracted, identical to legacy `vh`.
3. **`dvh` (Dynamic)**: Tracks the live toolbar state during [Render Tree & Layout](/concepts/render-tree-layout), resizing the element whenever toolbars animate.

```css
.app-viewport {
  /* Fallback for ancient engines, then Small Viewport */
  min-height: 100vh;
  min-height: 100svh;
}
```

Pair `min-height: 100dvh` with [CSS Scroll Snap](/concepts/css-scroll-snap) or fixed app shells carefully to avoid mid-scroll jumps.

## Interactive Labs & Dissections
- [CSS Scroll Snap Lab](https://frontend.rocks/concepts/css-scroll-snap/#lab) ([Markdown](https://frontend.rocks/concepts/css-scroll-snap.md))
- [Dynamic Viewport Units (dvh, svh, lvh) Lab](https://frontend.rocks/concepts/dynamic-viewport-units/#lab) ([Markdown](https://frontend.rocks/concepts/dynamic-viewport-units.md))

## Primary Sources
- https://drafts.csswg.org/css-scroll-snap-1/
- https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_scroll_snap
- https://drafts.csswg.org/css-values-4/#viewport-relative-lengths
- https://developer.mozilla.org/en-US/docs/Web/CSS/length#relative_length_units_based_on_viewport
