CSS & LayoutBaseline · Widely

Dynamic Viewport Units (dvh, svh, lvh)

Mental Model

On mobile browsers, 100vh equals the largest possible viewport (with the address bar hidden), pushing bottom buttons off-screen on load. svh locks to the small viewport (toolbars visible), lvh to the large viewport, and dvh resizes dynamically as toolbars collapse.

Interactive Simulator

100vh Mobile Clipping vs 100svh / 100dvh

Compare how mobile browser chrome interacts with vh, svh, and dvh.

Lines of Code
Before
5
After
6
Reflows / Browser Cost
Before
0 on scroll (clips bottom)
After
svh: 0 | dvh: on bar toggle
BeforeLegacy 100vh
.hero-screen {
  height: 100vh;
  display: grid;
  align-content: space-between;
}
Lines: 5Reflows: 0 on scroll (clips bottom)Dependencies: 0 JS

Bottom CTA hides under mobile URL bar on initial load.

After (Native)100svh / 100dvh
.hero-screen {
  min-height: 100svh; /* Safe & static */
  min-height: 100dvh; /* Dynamic if desired */
  display: grid;
  align-content: space-between;
}
Lines: 6Reflows: svh: 0 | dvh: on bar toggleDependencies: 0 JS

Fits cleanly above the mobile URL bar on first paint.

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, 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 or fixed app shells carefully to avoid mid-scroll jumps.

Problem Genealogy

  • 2015–2021: Developers hacked window.innerHeight * 0.01 into a --vh CSS variable on resize, causing initial load flashes.
  • 2022+: CSS Values Level 4 introduced sv*, lv*, and dv* units across all major browsers.

Production Pitfalls

Production Pitfall
  • 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.
When Not to Use
  • 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.

Connections & Logical Next Steps

CSS & LayoutDynamic Viewport Units (dvh, svh, lvh)
What This Unlocks
Leaf concept

Mechanical Comparisons