We’ve all been there: you throw height: 100vh on a hero section, fire up your desktop browser, and everything looks slick. Then you pull it up on your phone to show someone, and the bottom half of your call-to-action button is shoved right behind Safari’s address bar. It’s hands down one of the most annoying layout quirks in modern web dev, and mobile browsers have been driving us crazy with it ever since they started sliding their navigation chrome in and out.
Swap out
100vhfor100dvhwhenever you build full-height mobile hero sections.Stack a
100vhfallback right above it for safety:height: 100vh; height: 100dvh;.Keep
dvhaway from elements that constantly repaint, since scroll reflows can get choppy fast.
What Are vh and vw Units Anyway?
At their core, vh and vw are just viewport percentage units. Think of 1vh as 1% of the browser's viewable height, and 1vw as 1% of its width. They’re super handy because they let you size things directly against the actual viewport window, completely ignoring whatever parent containers wrap your element.
CSS
.hero {
height: 100vh; /* full viewport height */
width: 100vw; /* full viewport width */
}On a normal desktop monitor, this behaves cleanly without surprises. The real headache kicks in the second touch devices enter the picture.
The 100vh Mobile Bug: Why vh Feels Broken on Phones
Mobile browsers like Chrome and Safari use collapsible toolbars: the URL bar up top and the nav buttons down below shrink or vanish as you scroll downward. When someone first lands on your page, those bars are fully expanded. That means the actual usable real estate on screen is noticeably shorter than the theoretical space 100vh is calculating against.
Here’s the step-by-step breakdown of what goes wrong:
A visitor opens your site, and the browser displays its full top and bottom toolbars.
The browser calculates
100vhusing the largest possible screen height (assuming toolbars are gone).Your
100vhblock winds up overflowing the actual visible screen by the exact height of those bars.Your user gets stuck with a cut-off hero banner or an accidental vertical scrollbar.
Back around 2015–2016, the engineering teams behind Safari and Chrome intentionally decided that 100vh should match the viewport with all bars tucked away. They did this to prevent the entire page layout from visibly jerking every time you scrolled, but it saddled the rest of us with an awkward overflow bug that still trips up devs today.
The Old Hacks We Used to Rely On
Before native CSS units came along to rescue us, we usually had to glue together a couple of clunky workarounds:
The JavaScript listener trick:
JavaScript
function setVh() {
document.documentElement.style.setProperty(
'--vh', `${window.innerHeight * 0.01}px`
);
}
window.addEventListener('resize', setVh);
setVh();CSS
.hero {
height: calc(var(--vh, 1vh) * 100);
}The WebKit vendor prefix:
CSS
.hero {
height: 100vh;
height: -webkit-fill-available;
}Honestly, both had serious flaws. The JS route forced an extra event listener onto resize events and frequently triggered nasty layout thrashing. Meanwhile, -webkit-fill-available only helped out in WebKit engines, behaved inconsistently across iOS releases, and didn't solve Android issues at all.
I ran smack into this exact issue a while back when putting together a marketing splash that needed seamless full-height panels across iOS and Android. Safari seemed fine with the WebKit rule, but Chrome on Android completely ignored it and left an ugly chunk hanging off the screen edge. Swapping all of that mess out for dvh paired with a vanilla vh fallback fixed both operating systems in two lines of CSS.
Enter dvh, lvh, and svh: The Clean Solution
The CSS Working Group finally tackled this head-on by standardizing three new sets of viewport units. Browser support is solid across the board now: Chrome 108+, Firefox 101+, and Safari 15.4+ have you completely covered.
svh (Small Viewport Height)
Think of svh as measuring the screen when the browser’s interface is taking up the absolute most room - meaning every toolbar, URL bar, and nav bar is fully visible. 1svh equals 1% of the smallest possible viewport window.
Reach for svh whenever you want a container guaranteed to fit inside the screen on page load without any hidden overflow:
CSS
.hero {
height: 100svh;
}This guarantees your visitor won't have their CTA button tucked underneath the bottom navigation bar on that initial impression.
lvh (Large Viewport Height)
On the flip side, lvh looks at the viewport when browser chrome takes up the least possible room, meaning the toolbars have collapsed or slid off-screen. 1lvh equals 1% of that maximum possible height.
In daily use, lvh behaves almost identically to classic vh. It’s mostly useful when you want to be totally intentional and explicit in your stylesheet about sizing against the expanded view:
CSS
.background-image {
min-height: 100lvh;
}dvh (Dynamic Viewport Height)
dvh is the smart unit that actively recalculates on the fly. When your user is at the top of the page with the bars shown, 100dvh equals 100svh. Once they scroll down and those bars slide out of sight, 100dvh automatically grows to match 100lvh.
CSS
.fullscreen-section {
height: 100dvh;
}Where dvh shines: Full-height intro banners, splash cards, modal dialogs, or anything that genuinely needs to hug the exact visible frame no matter where the toolbars are.
Where to steer clear: Anything with heavy animations, parallax effects, or constant repaints. Since dvh recalculates values whenever toolbars toggle, it forces the browser to run layout reflows while scrolling.
Even the CSS spec flags this: "Using these units can cause content to resize while the user scrolls the page. Depending on usage, this can be disturbing to the user and/or costly in terms of performance."
A Quick Cheat Sheet: vh vs svh vs lvh vs dvh
| Unit | What It Targets | Behavior on Mobile (Toolbar Open) | Behavior on Mobile (Toolbar Hidden) | Recalculates While Scrolling? |
|---|---|---|---|---|
vh |
Large (static) | Overflows; too tall | Fits cleanly | No |
svh |
Small (static) | Fits cleanly | Leaves a small gap | No |
lvh |
Large (static) | Overflows; too tall | Fits cleanly | No |
dvh |
Dynamic (adaptive) | Fits cleanly | Fits cleanly | Yes |
On typical desktop setups where browser chrome never resizes dynamically, all four of these evaluate to the exact same pixel value.
The Width Equivalents: vw, svw, lvw, dvw
Just so you know, the exact same rules exist on the horizontal axis. You won’t run into them quite as frequently since mobile browsers rarely tuck away side panels, but the full spec is ready if you need it:
svw/lvw/dvwhandle raw viewport widthssvi/lvi/dvitrack your inline axis (adapting to writing modes)svb/lvb/dvbadapt along your block axissvmin/svmax/lvmin/lvmax/dvmin/dvmaxgrab min/max bounds across width and height
In day-to-day client work, you’ll spend 95% of your time dealing with the vertical height units (dvh, svh, and lvh) rather than the horizontal set.
Common Layout Patterns You’ll Actually Use
Full-Screen Hero on Mobile
CSS
.hero {
height: 100dvh;
display: flex;
align-items: center;
justify-content: center;
}Full-Screen with Safe Browser Fallbacks
CSS
.hero {
height: 100vh; /* fallback */
height: 100dvh; /* modern browsers override */
}Any legacy browser that hasn't implemented dvh simply skips past the unknown property and comfortably defaults to standard 100vh.
Keeping the Footer Pinned
CSS
.page-wrapper {
min-height: 100svh;
display: flex;
flex-direction: column;
}
.main-content {
flex: 1;
}Using svh here is great because it ensures your sticky footer rests cleanly at the bottom without accidentally slipping below the fold on initial load.
Full-Screen Mobile Modal
CSS
.modal-overlay {
position: fixed;
inset: 0;
height: 100dvh;
background: rgba(0, 0, 0, 0.5);
}Modals are supposed to cover whatever the user can actually see. Layering dvh here keeps the backdrop glued to the actual viewport as toolbars adjust.
Traps to Avoid
Mixing static and dynamic units in one tree. If you set a parent wrapper to 100vh and give its child 100dvh, they’re referencing two entirely different measurements. The child will end up misaligned or clipping through. Pick one mental model for the component and stick with it.
Putting dvh on intense scroll animations. Throwing a dvh rule onto a parallax container forces continuous recalculations whenever browser bars retract. That layout thrashing can easily crater your frame rate down from 60fps. Stick with svh or lvh for animated heavy-hitters.
Skipping the fallback line. Around 4% of traffic worldwide still visits from older engines - mostly outdated Android WebViews and niche embedded browsers. It costs you nothing to keep standard vh right above your new unit:
CSS
.element {
height: 100vh;
height: 100dvh;
}Pairing dvh with position: fixed in Safari. On certain iOS versions, fixed elements driven by dvh can occasionally stutter or snap during toolbar expansion. If you ever spot that flickering bug in testing, switch over to svh to keep things completely static.
What About the On-Screen Keyboard?
Keep in mind that when a mobile virtual keyboard pops up, it does not automatically resize your standard viewport units by default. Your 100dvh wrapper stays pinned to its original size, meaning the software keyboard will just slide over top of half your content.
In Chrome, you can override that behavior by declaring the interactive-widget meta tag:
HTML
<meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">Using resizes-content forces viewport units to shrink down when the keyboard appears, which is super helpful for chat apps or long forms. Leaving it on the default overlays-content keeps the classic floating behavior intact.
Where Does Browser Support Stand?
Every major modern browser has shipped solid support for dvh, svh, and lvh since early 2023:
| Browser | Supported Version | Arrival Date |
|---|---|---|
| Chrome | 108+ | December 2022 |
| Firefox | 101+ | May 2022 |
| Safari | 15.4+ | March 2022 |
| Edge | 108+ | December 2022 |
| Samsung Internet | 20+ | Early 2023 |
Can I Use puts global browser availability well above 96%. You're really only working around legacy embedded WebViews and discontinued mobile systems at this point.
Working with dvh in Tailwind CSS
Tailwind’s standard h-screen class still defaults to plain old 100vh. If you want to tap into the new dynamic units, here are two straightforward ways to handle it:
Using arbitrary classes directly:
HTML
<div class="h-[100dvh]">Full dynamic viewport height</div>
<div class="h-[100svh]">Full small viewport height</div>Registering custom theme tokens (Tailwind v4):
CSS
@theme {
--height-dvh: 100dvh;
--height-svh: 100svh;
}Once that's added, you can cleanly apply h-dvh and h-svh wherever you want. If you're already tweaking your setup with custom values in Tailwind CSS v4, this slots right into your existing architecture.
And if you're experimenting with clean approaches to dark mode with CSS, pairing modern viewport tokens with native utility functions makes responsive design feel way more cohesive.
Heading into your daily workflow today, treating dvh backed by a vh safety line as your default rule of thumb will save you hours of debugging. Just lean on svh whenever initial-load stability is paramount, and keep lvh in reserve for the rare times you want to lock against an expanded canvas.