🌐 Modern Viewport Units β€” svh, svw, lvh, lvw Explained

What Are Modern Viewport Units?

Traditional viewport units (vh, vw) have long struggled on mobile browsers due to dynamic UI bars (address bar, navigation bar) appearing and disappearing. Modern CSS introduces new units to fix these issues and give developersprecise, reliable viewport measurements.

>>β€œModern viewport units finally give full control over mobile sizing β€” no more jumpy layouts.”

Note

βœ” Supported in all major modern browsers
βœ” Essential for mobile-first, fullscreen layouts
βœ” Works together with dvh/dvw

πŸ“¦ The 4 Modern Viewport Units

UnitMeaningRepresents
svhSmall Viewport HeightHeight when browser UI is fully visible (smallest possible)
svwSmall Viewport WidthWidth when UI reduces viewport (rare)
lvhLarge Viewport HeightHeight when browser UI is fully hidden (largest possible)
lvwLarge Viewport WidthWidest possible width

Note

πŸ”₯ svh = smallest height
πŸ”₯ lvh = largest height
πŸ”₯ dvh = dynamic, updating height

πŸ“Œ Syntax

Syntax

height: 100svh;  /* Small viewport height */
height: 100lvh;  /* Large viewport height */
width: 100svw;   /* Small viewport width */
width: 100lvw;   /* Large viewport width */

🧠 Why Do We Need These Units?

Mobile browser UI bars appear/disappear when scrolling. This causes the traditional 100vh unit to:

  • Make content jump suddenly
  • Cut off bottom sections
  • Show blank space at the bottom
  • Create unpredictable layouts
>>β€œsvh, lvh, and dvh offer predictable, reliable sizing across all states.”

πŸ“ Understanding Each Unit

1️⃣ svh β€” Small Viewport Height

Represents the minimum height of the viewport (when the browser UI is fully visible).

svh Example

.safe-section {
  height: 100svh;
}

Useful when you want to avoid layout shifting on scroll.

2️⃣ lvh β€” Large Viewport Height

Represents the maximum height the viewport can reach (when browser UI collapses).

lvh Example

.fullscreen {
  height: 100lvh;
}

Perfect for true fullscreen on mobile apps.

3️⃣ svw β€” Small Viewport Width

Smallest width visible (rarely changes except with side UI panels).

svw Example

.sidebar {
  width: 20svw;
}

4️⃣ lvw β€” Large Viewport Width

Largest possible viewport width β€” useful for responsive hero designs.

lvw Example

.wide-banner {
  width: 100lvw;
}

πŸ§ͺ Practical Examples

πŸ“± 1. Stable Mobile Hero Section

Stable Hero

.hero {
  height: 100svh; /* Prevent jumpiness */
  background: url(hero.jpg) center/cover;
}

πŸš€ 2. True Fullscreen Mode

Full Screen

.hero-expanding {
  height: 100lvh; /* Tallest height available */
}

πŸ“ 3. Dynamic App Layout (best UX)

Dynamically Adjusting Layout

.page {
  min-height: 100dvh; /* Updates as UI changes */
}

Combine with svh & lvh for best control.

🎯 4. Responsive Typography Using vmin and vmax

Typography

.title {
  font-size: 5vmin;
}

Works well with modern viewport units to scale proportions.

🧬 How These Units Work Together

Scenariosvhlvhdvh
Browser UI visibleβœ” Accurate❌ Too largeβœ” Accurate
Browser UI hidden❌ Too smallβœ” Accurateβœ” Accurate
UI changing during scroll❌ Static❌ Staticβœ” Updates live

Note

πŸ’‘ Use dvh when you want dynamic behavior.
πŸ’‘ Use svh or lvh when you want stability.

⚠️ Common Mistakes

  • ❌ Still using 100vh for mobile layouts
  • ❌ Assuming svh updates on scroll (it doesn’t)
  • ❌ Using lvh in components that shouldn’t jump on scroll
  • ❌ Not testing on different mobile browsers

Note

🎯 Best Practice:
Use dvh when you want dynamic behavior,
Use svh or lvh when you want stability.

πŸ”₯ Summary

Modern viewport units (svh, svw, lvh, lvw) finally solve the classic mobile viewport bug by providing stable and predictable sizing. Combined with dvh/dvw, they give designers full control over fullscreen layouts on mobile browsers.

>>β€œModern viewport units make mobile web design truly reliable and predictable.”

Learn more β†’MDN Docs πŸ“˜