CSS Scroll Snap vs Dynamic Viewport Units (dvh, svh, lvh)
Scroll snap aligns scrollport rest positions, whereas dynamic viewport units resize snapports as mobile toolbars animate.
Structured Comparison Matrix
| Dimension | CSS Scroll Snap | Dynamic Viewport Units (dvh, svh, lvh) |
|---|---|---|
| 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. |
| Maturity & Domain | Baseline · Widely · CSS & Layout Chrome 69+ · Firefox 68+ · Safari 11+ | Baseline · Widely · CSS & Layout Chrome 108+ · Firefox 101+ · Safari 15.4+ |
| Prerequisites | ||
| 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. |
Engine Mechanics & Trade-Offs
Layout collects child snap rects; the Compositor Thread predicts fling velocity and lands cleanly on the nearest snap point.
Key Pitfalls: Trapping tall content with mandatory: Using y mandatory on sections taller than the viewport prevents users from reading the bottom half of a section. Skipping slides on fast swipes: Without scroll-snap-stop: always, a fast swipe jumps across multiple slides at once.
100vh maps to the Large Viewport (lvh); 100svh locks to the Small Viewport; 100dvh triggers layout recalculation when toolbars animate.
Key Pitfalls: Using 100dvh everywhere: Applying height: 100dvh to long-scrolling landing page sections triggers Layout reflows while the user's thumb drags the page. height instead of min-height: Hardcoding height: 100svh clips overflowing content on landscape phones; always prefer min-height.