Modern CSS Viewport Units in 2026: dvh, svh, lvh Explained

Modern CSS Viewport Units: dvh, svh, lvh Explained

The mobile address-bar problem that broke 100vh for years is solved. Small (svh), large (lvh), and dynamic (dvh) units explained, with the migration plan.

The mobile address-bar problem that broke 100vh for years is solved at the platform level. Three new viewport unit families ship in every modern engine: small (svh, svw, svi, svb) sized against the smallest viewport when chrome is visible, large (lvh, lvw, lvi, lvb) sized against the largest viewport when chrome is hidden, and dynamic (dvh, dvw, dvi, dvb) that recompute as chrome shows and hides. The three families became Baseline Newly available in December 2022 and Widely available in June 2025. This guide explains when each unit is the right choice, the dynamic-recompute trade-off, and the migration plan that retires the JavaScript --vh polyfill.

The 100vh problem on mobile

Major mobile browsers show and hide browser chrome — the URL bar, the toolbar, the tab strip — as the user scrolls. When the address bar is visible, the visual viewport is shorter; when hidden, it is taller. The same page in the same orientation has two different visible heights depending on a UI behavior the page does not control.

For years 100vh has resolved to the larger of the two viewports — the height when chrome is hidden. A hero section sized height: 100vh would extend past the visible bottom edge whenever the address bar was actually showing. The "fold" became unreliable. Forms sized to fit the screen would have their submit button buried below the address bar. Mobile-first sites accumulated workarounds.

The classic JavaScript polyfill was painful. Code listened for resize events, measured window.innerHeight, and wrote a --vh custom property that the CSS could read instead of 100vh:

js
function setVH() {
  document.documentElement.style.setProperty(
    '--vh',
    `${window.innerHeight * 0.01}px`
  );
}
window.addEventListener('resize', setVH);
setVH();
css
.hero { height: calc(var(--vh) * 100); }

The pattern was never fully reliable. resize events can fire while the chrome animates, which can cause visible layout jumps. The --vh value was correct only at the moment the listener last fired.

The 2022 platform fix bakes the dynamic behavior into CSS so JavaScript is no longer needed for the address-bar case.

The new viewport unit family

Three families plus the original two-letter units cover every layout intent. Each family has four axis members — two physical axes (width / height) and two logical axes (inline / block) — plus min and max variants (svmin, svmax and so on) that this guide does not cover.

FamilyMembersSized against
Small`svh`, `svw`, `svi`, `svb`Smallest viewport — chrome visible. The unit never causes overflow when the address bar is showing
Large`lvh`, `lvw`, `lvi`, `lvb`Largest viewport — chrome hidden. The unit never has gaps when the address bar is hidden
Dynamic`dvh`, `dvw`, `dvi`, `dvb`Recomputes as chrome shows and hides — follows the current visible viewport, with updates throttled while the browser UI animates
Original`vh`, `vw`, `vi`, `vb`Equivalent to the large family — sized against the largest viewport

The logical-axis variants — svi / svb, lvi / lvb, dvi / dvb — are writing-mode-aware. svi is the inline dimension (width in horizontal writing modes, height in vertical Japanese), svb is the block dimension. For a 20-locale site that includes vertical writing modes, the logical units are correct by default; the physical-axis variants (svh / svw) match horizontal writing modes only.

vh and vw continue to exist and are equivalent to lvh and lvw. The platform did not change the meaning of the original units, which would have broken every site shipping 100vh. Instead, it added the small, large and dynamic families and kept the originals stable, with the large family matching them.

When to use each unit

The choice maps to the layout intent.

svh is the safe default for above-the-fold content that must always be visible without scrolling, regardless of chrome state. Welcome screens, single-screen forms, mobile splash sections, sticky-foot calls-to-action that should fit when chrome shows. The unit guarantees the section never overflows when the address bar is visible.

lvh is for hero sections that should fill the full chrome-hidden screen but are allowed to be larger than the chrome-visible screen. Editorial heroes, immersive intro sections, full-bleed landing pages where the user can scroll if chrome is taking screen space. The unit guarantees the section reaches the bottom of the viewport when chrome is hidden, accepting that the user may need to scroll a small amount when chrome is visible.

dvh is for full-screen experiences that should track the visible area as it changes. Slideshows, photo viewers, sticky bottom sheets, bottom toolbars that hug the visible edge. The unit recomputes as chrome shows and hides, so the layout follows, in throttled steps while the chrome animates.

A common mistake is using dvh for re-flowing content. A long article column sized with dvh-based padding will jitter as the address bar appears and hides; the layout will visibly shift, and the user reads a wobbling page. Re-flowing text content should use svh or fixed pixel measurements; dvh belongs on elements whose role is to hug the visible edge.

Combining the small and large units in one rule does not produce a section that resizes with the chrome:

css
.hero {
  min-height: 100svh;
  height: 100lvh;
}

Because lvh is never smaller than svh, the min-height never applies: the hero is always exactly the chrome-hidden height. It fills the screen when chrome is hidden; when chrome is visible, it extends below the visible edge, and part of it can be hidden behind the browser UI. For a section that must fit when chrome is visible and grow with its content, use min-height: 100svh alone (see Patterns below).

The dynamic-recompute caveat

dvh recomputes as the address bar shows and hides, which makes it the right choice for elements that should track visibility — and the wrong choice for elements that should not.

Animations and transitions on dvh-based properties can look stuttery during the chrome animation. The browser throttles the recompute, so the value updates discretely, not continuously, during the address-bar slide. A transform animation that depends on dvh will snap rather than glide.

Scroll-snap targets bound to dvh are problematic. A full-screen snap carousel with scroll-snap-type: y mandatory on the container and scroll-snap-align: start plus height: 100dvh on each slide can see its snap positions shift when the dynamic viewport size updates, which can produce unexpected snap behavior at the moment chrome transitions are most likely (the user just scrolled). Size the slides in svh or lvh instead.

The Visual Viewport API still has a role for elements that need to react to the keyboard appearing on mobile, which is not the same as the address bar. The keyboard's appearance is exposed through window.visualViewport.height, which is more precise than dvh for keyboard-aware layout (a chat input that sits above the keyboard, a sticky toolbar that moves up when the keyboard opens). dvh tracks the layout viewport; the Visual Viewport API tracks the visual viewport, including the keyboard inset.

Real-device testing matters. Emulators and DevTools mobile modes do not always reproduce the chrome animation correctly — desktop mobile previews may not reproduce how the address bar shows and hides, so some bugs surface only on real hardware. Add at least one real-device pass to the design-system layout review.

Cross-engine availability

The three new families became Baseline Newly available in December 2022 and Widely available in June 2025 (web-features). Safari shipped them in Safari 15.4 (March 2022), Firefox followed in Firefox 101 (May 2022), and Chromium completed the set in Chrome and Edge 108 (late 2022).

Older browsers fall back gracefully without explicit @supports gating. An unrecognized unit causes the property declaration to drop, so a layered declaration works as a feature query implicitly:

css
.hero {
  height: 100vh;       /* fallback: usually sized like lvh in legacy mobile engines */
  height: 100svh;      /* preferred: small viewport, takes precedence in modern engines */
}

Browsers that recognize 100svh use the second declaration; browsers that do not, drop it and fall back to 100vh. The pattern is correct without @supports.

For cases where an entire layout block depends on dynamic behavior — for example, a slideshow component that only makes sense with dvh — explicit feature detection is appropriate:

css
@supports (height: 100dvh) {
  .slideshow { height: 100dvh; }
}

@supports not (height: 100dvh) {
  .slideshow { height: 100vh; }
}

This is rare; most layouts work fine with the layered-fallback pattern. The 100vh JavaScript polyfill (the --vh custom property + window resize listener) can finally be retired in 2026 — every engine that meaningfully ships traffic supports the new units natively, the polyfill's cost outweighs its remaining benefit, and the workaround was always imperfect.

Patterns

A handful of recipes cover most layouts.

A hero with a safe minimum height that grows with its content:

css
.hero {
  min-height: 100svh;
  display: grid;
  place-items: center;
}

Uses the small viewport so chrome visibility never causes overflow; allows the hero to grow if its content needs more space.

A modal full-screen on mobile that tracks the visible area:

css
.modal {
  position: fixed;
  inset: 0;
  height: 100dvh;
}

Tracks the visible area as browser chrome shows and hides, so the modal always covers the screen. It does not follow the on-screen keyboard by default: as of October 2026, Safari on iOS and Chrome on Android (since Chrome 108) resize only the visual viewport when the keyboard opens, so viewport units stay put. If the modal holds a form that must stay above the keyboard, read window.visualViewport.height as described above, or opt into interactive-widget=resizes-content in the viewport meta tag, which Chrome and Firefox on Android honor but Safari does not yet ship (as of October 2026, caniuse).

A sticky bottom action bar that respects the iOS safe area:

css
.action-bar {
  position: fixed;
  bottom: 0;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.scroll-region {
  box-sizing: border-box;
  height: 100svh;
  padding-bottom: 4rem; /* room for the bar */
}

The surrounding container uses svh for safety; the bar uses safe-area-inset-bottom for iOS notch / home-indicator clearance.

A split-screen layout where each column should fit when chrome is visible:

css
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.split > * {
  height: 100svh;
  overflow: auto;
}

Each column's content is scrollable independently; neither column's chrome triggers a viewport overflow.

A photo viewer for true full-screen with chrome auto-hiding:

css
.photo-viewer {
  position: fixed;
  inset: 0;
  height: 100dvh;
}

Tracks the visible viewport as the browser's address bar and toolbars show and hide. The user sees the photo fill the screen at all chrome states.

Migration from 100vh

The migration is mostly mechanical, and it removes a script along with its resize listener.

Audit the codebase for vh and vw. List every occurrence and the surrounding context — what is the section's role, does it want the small / large / dynamic semantics?

Replace 100vh with the appropriate unit based on the section's intent. Default to svh when in doubt, because it is the safe choice. Use lvh for sections that should fill the full screen when chrome is hidden. Use dvh for elements that hug the visible edge.

Remove the JavaScript address-bar workarounds — the --vh custom property setter, the window.resize listener, the setVH() helpers. These were never fully reliable; the platform now does the work correctly.

Verify visually on iOS Safari, Chrome Android, and a tablet. iOS Safari and Chrome Android cover the WebKit and Chromium engines on mobile; add Firefox for Android if your audience uses it. A real-device pass on each is worth the time; emulators do not always reproduce chrome animation faithfully.

Document the choice in the design-system layout primitive's README. The next maintainer needs to know that the height: 100vh; height: 100svh; fallback pair is intentional, not a typo — without the documentation, someone will "simplify" it back to height: 100vh.

Migration priorities for the next planning cycle

  • Audit the codebase for 100vh and 100vw usages; list each with its layout role
  • Replace each with svh / lvh / dvh (or the writing-mode-aware logical variants) based on intent; default to svh for safety
  • Remove the JavaScript --vh polyfill — the window.resize listener and the --vh custom property setter
  • Add the layered fallback pattern (height: 100vh; height: 100svh;) where graceful degradation matters; use @supports only when an entire block depends on the dynamic behavior
  • Test the migration on real iOS Safari, Chrome Android, and a tablet — chrome animation behavior can differ from emulators
  • Document the unit choice in design-system layout primitive README files so future maintainers do not regress to 100vh
Project Inquiry