Layout Beginner

Mobile viewport height without the 100vh hack

100vh on mobile includes the browser address bar and navigation controls even when they are visible, causing full-height elements to overflow. Dynamic viewport units (dvh, svh, lvh) adapt to the actual visible area.

βœ“ Modern
3 lines
1.hero {
2  height: 100dvh; /* shrinks with address bar */
3}
βœ• Old 3 lines
1.hero {
2  height: 100vh; /* overflows behind browser chrome */
3}
Widely available Since 2023 93% global usage

This feature is well established and works across many devices and browser versions. It has been available across browsers since 2023.

108+
101+
15.4+
108+
dvh vs vh β€” mobile browser toolbar awareness
100vh (old)
browser toolbar
100vh
(overflows)
Content cut off
100dvh (modern)
browser toolbar
100dvh
(fits)
Always visible
svh
toolbar visible
dvh
current state
lvh
toolbar hidden
min-height: 100dvh β€” dynamic viewport height
πŸ“±

No mobile overflow

100dvh accounts for the browser address bar and navigation. It shrinks when the bar is visible and expands when it scrolls away.

✦

Three units for three needs

dvh is dynamic (changes with chrome), svh is small (worst case, chrome fully visible), lvh is large (best case, chrome fully hidden).

∞

Drop-in replacement on desktop

On desktop where viewport height is stable, dvh behaves identically to vh. Switch freely without breaking existing layouts.

Old Approach
height: 100vh
Overflows behind browser chrome on mobile
Modern Approach
height: 100dvh
Adapts to visible viewport area
Three Variants
dvh / svh / lvh
Dynamic, small, and large viewport heights

How it works

On mobile browsers, 100vh is calculated including the address bar and navigation controls even when they overlay the page. A height: 100vh element ends up taller than the visible screen, pushing content behind the browser chrome.

Dynamic viewport units solve this. dvh updates as the browser chrome appears and disappears. svh is the small viewport height β€” the worst case with chrome fully visible. lvh is the large viewport height β€” chrome fully hidden. For full-screen sections, replace 100vh with 100dvh.

New CSS drops.

Join 400+ readers who've survived clearfix hacks.

ESC