Skip to main content
Three phones comparing svh with visible toolbars, lvh with hidden toolbars, and dvh resizing while scrolling

Why your 100vh hero gets eaten by the mobile address bar

Some CSS bugs stick with you. The hero section that looks perfect on your laptop and then gets swallowed by the browser toolbar on your phone is one of mine. I lost a whole afternoon to it once, and the culprit wasn’t a typo — it was 100vh doing exactly what the spec says it does.

So let’s talk about full-height layouts: why height: 100% keeps betraying people, why 100vh lies to you on mobile, and how the newer units (dvh, svh, lvh) fix all of it.

Why height: 100% rarely works

100% is a percentage of the parent, not the screen. That’s the whole trap.

.hero {
  height: 100%;
}

If the parent has no height of its own, this quietly does nothing. The browser can’t resolve a percentage against “whatever height you feel like,” so the element falls back to auto and just hugs its content. No error, no warning. It just doesn’t work.

To make it work, every single ancestor needs a height:

html,
body {
  height: 100%;
}

.hero {
  height: 100%;
}

And I mean every ancestor. One extra <div> wrapper someone added “just to be safe” and the chain breaks again. This whole approach feels like a stack of dominoes, which is why everybody jumped to viewport units as soon as they could.

So why not just 100vh?

Viewport units skip the parent chain entirely. 100vh means 100% of the viewport height, parents be damned:

.hero {
  height: 100vh;
}

On desktop, great, ship it. On mobile… hold on.

The problem: mobile browsers hide and show the address bar depending on where you scroll. So what is the height of the viewport? When you’re at the top of the page with the address bar showing, or mid-scroll when the bar has collapsed away?

The spec’s answer is that 100vh always means the viewport when the browser UI is fully hidden, the tallest possible viewport. Which means that at the top of the page, where everyone looks first, your 100vh hero is taller than the visible screen. The bottom gets shoved under the toolbar, or worse, the page grows a scrollbar to accommodate empty space that isn’t even visible yet.

There’s also a quirk that catches people off guard: vh doesn’t update while you scroll. The address bar collapses and reappears, but 100vh stays frozen at the value from the initial layout. This is deliberate. If viewport units tracked the moving address bar in real time, every scroll would reflow the page and things would jitter around. Annoying, but the spec authors had a point.

svh and lvh: admitting the viewport has two sizes

The modern fix was to stop pretending the viewport has one height. The spec now splits it in two.

100svh is the small viewport, meaning every browser toolbar is visible. The worst case. It’s the honest unit: it fits on screen right now, toolbar and all, so nothing gets hidden and no mystery scrollbar shows up. If you want a section that’s guaranteed fully visible the moment the page loads, this is the one.

.hero {
  height: 100svh;
}

100lvh is the opposite bet. It’s sized for the fully-open screen with all UI hidden, so you’re accepting that some of it might sit off-screen until the user scrolls. Fine for full-screen backgrounds, less fine for a CTA button.

And dvh? That’s the one that moves

dvh is the dynamic viewport height. Instead of picking a fixed state, it tracks the viewport as it is right now, resizing continuously as the address bar slides away and back.

.hero {
  height: 100dvh;
}

This is what most people thought they were getting when they typed 100vh. It’s also the one with a real cost: since dvh changes during scroll, anything sized with it changes too. On a fast phone you barely notice. On a slow one, you can get visible reflow or jank as the address bar animates. I’ve seen sticky footers “breathe” during scroll because of this.

Whether that trade-off is acceptable depends on the design. Sometimes it is, sometimes it very much isn’t.

What I actually reach for

.hero {
  min-height: 100svh;
}

@supports (min-height: 100dvh) {
  .hero {
    min-height: 100dvh;
  }
}

Start with 100svh as the reliable baseline, upgrade to 100dvh where it’s supported, and let the browser decide. For really old browsers, a plain 100vh line before the modern ones costs one line and covers your back:

.hero {
  height: 100vh;   /* fallback */
  height: 100dvh;  /* modern browsers */
}

For choosing between the units, the shorthand version of how I think: if the parent already has a height (or you’re stretching children with flex/grid), just use 100%. If it must be fully visible, always, use 100svh. If you want it hugging the real viewport and can live with scroll-time resizing, 100dvh. And when oversized is fine — backgrounds, scroll-triggered stuff — that’s 100lvh territory.

Support is genuinely good now. Chrome 108, Safari 15.4, Firefox 101 and up. Unless you’re supporting ancient mobile browsers, you can use these today.

The cheat sheet

Unit Means Changes on scroll? Gotcha
% % of parent No Dead unless ancestors have height
vh Fixed “tall” viewport No Overflows behind mobile toolbars
svh Smallest viewport No Slightly shorter than the screen at best
lvh Largest viewport No Content off-screen until scrolled
dvh Current viewport Yes Resize/jank during scroll

Next time a 100vh section breaks on a phone, you’ll know it’s not a bug — it’s the spec working as designed, against you.

References