The blog

The Address Bar Ate Your Hero

You built a gorgeous full-screen hero. Big photo, confident headline, a “Book a Consultation” button sitting right at the bottom like a welcome mat. It looks perfect on your laptop. Then you pull it up on your phone, and the button is gone. Not broken, just hiding behind the browser’s toolbar, like a cat under the bed.

The culprit is one innocent-looking line of CSS: height: 100vh. On a phone, 100vh isn’t the height of the screen you’re actually looking at. Let’s fix that properly, with the newer viewport units, sensible fallbacks, and a few safety nets for notches, keyboards and sticky buttons.

Why 100vh Lies on Your Phone

Mobile browsers have toolbars that come and go. When the page first loads, the address bar and bottom toolbar are showing. Start scrolling, and they shrink or slide away to give you more room. So which height is “the viewport”? The one with the toolbars, or the one without?

Browsers picked “without.” The CSS Values and Units spec now says plainly that the classic vh unit maps to the large viewport, the size you get when all that retractable browser UI is tucked away. MDN puts it the same way: vh is equivalent to lvh. That means a 100vh hero is taller than the screen the moment someone lands on your page, and whatever sits at the bottom of it (your headline’s second line, your scroll cue, your call-to-action button) is tucked under the toolbar.

Two outlined phone diagrams on a dark blueprint grid. On the left, a 100vh hero is taller than the visible screen, so the Book a Consultation button sits hidden under the bottom browser toolbar. On the right, a 100svh hero fits between the address bar and the toolbar, and the button stays in view.
A 100vh hero is sized for the toolbars-hidden viewport, so the call-to-action can land under the toolbar on arrival. 100svh fits the screen with the toolbars showing.

On a desktop browser, none of this matters. There are no disappearing toolbars, so web.dev notes that the small, large and dynamic viewports are all the same size there. That’s exactly why this bug sails through testing on your laptop and gets caught by a customer’s thumb.

Meet svh, lvh and dvh

To fix this, CSS gave us three flavors of viewport height, defined in that same spec and now supported in every major browser engine:

  • svh (small viewport height) is measured with the toolbars showing. Content sized with it fits on screen even in the most cramped state. It’s stable: it doesn’t change as you scroll.
  • lvh (large viewport height) is measured with the toolbars hidden. It fills the screen once the bars retract, but can be partly covered when they’re visible. Also stable.
  • dvh (dynamic viewport height) tracks whatever is true right now, shrinking and growing as the toolbars move.
Three outlined phone diagrams on a dark blueprint grid comparing viewport units. The svh phone shows the address bar and bottom toolbar, with a shorter 100svh height mark between them. The lvh phone shows the toolbars retracted and a taller 100lvh height mark. The dvh phone shows a 100dvh height mark between those two sizes, tracking the current height.
svh is the height with the toolbars showing, lvh is the height with them hidden, and dvh tracks whatever is true right now.

Here’s the analogy that makes it click. Think of your hero as a stage set and the browser toolbar as a curtain that keeps dropping in and out. svh builds the set to fit with the curtain down, so nothing is ever hidden, though you might see a little bare stage when the curtain rises. lvh builds for the curtain up, so it looks spectacular until the curtain drops and covers the actors’ feet. And dvh? That’s stagehands shoving the scenery around every time the curtain moves, mid-scene, while the audience watches.

That last part isn’t just a metaphor. The spec warns that dynamic units “can cause content to resize e.g. while the user scrolls the page,” which can be “disturbing to the user and/or costly in terms of performance.” Web.dev adds that browsers throttle or even debounce dvh updates, so it doesn’t glide smoothly anyway. That’s why “just use dvh” isn’t the whole answer.

The Fix for a Typical Small-Business Hero

For a hero whose content must be visible on arrival (headline, subhead, button), reach for svh. Pair it with a vh fallback for older browsers, and use min-height instead of height:

/* Full-screen hero that always fits */
.hero {
  min-height: 100vh;  /* fallback for older browsers */
  min-height: 100svh; /* fits with the toolbars showing */
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
}

The fallback works because of the cascade: a browser that doesn’t understand svh throws that declaration away and keeps the one above it. No JavaScript, no feature detection. If you prefer to be explicit (or you’re changing several properties at once), @supports does the same job:

/* Same idea, explicit feature check */
.hero { min-height: 100vh; }

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

Why min-height? Because height is a promise you can’t keep. Your hero copy will wrap differently on a narrow phone, a visitor might bump up their text size (a great reason to size type with em and rem units), and a phone held sideways has a viewport about as tall as a business card. With height: 100svh, extra content spills out of the box and collides with the next section. With min-height, the hero is at least one screen tall and grows when it needs to.

Where lvh and dvh Earn Their Keep

svh is the safe default, but the other two aren’t useless. They just have narrower jobs.

Use lvh for decoration that should never show a gap. A fixed, full-page background is the classic case. Size it to the small viewport and you can get a strip of bare page when the toolbars hide. Size it to the large viewport and it always covers, and if a toolbar overlaps the bottom edge, who cares? It’s a background.

/* Fixed backdrop: never shows a gap when toolbars hide */
.backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100lvh;
  z-index: -1;
}

Use dvh when the page isn’t scrolling underneath. A full-screen mobile menu or a modal with a button pinned to its bottom edge are good fits. Because the visitor isn’t scrolling the page while it’s open, the toolbars aren’t bouncing around, and dvh simply means “exactly the space you have.” Avoid it on long, scrolling sections, where it turns every flick of the thumb into a layout recalculation.

Notches, Home Bars and viewport-fit=cover

Modern phones aren’t rectangles. Rounded corners, camera cutouts and the home indicator all eat into the screen. By default, browsers keep your page inside a safe rectangle. If you want your hero photo to run edge to edge, opt in with viewport-fit=cover in your viewport meta tag:

<!-- Let the page draw under notches and rounded corners -->
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">

Now you’re responsible for keeping text and buttons out of the danger zones. MDN’s viewport reference “highly recommends” the safe-area inset variables for exactly this, and the env() function exposes them. They’re 0 on a plain rectangular screen, so they’re harmless everywhere else. Combine them with max() and CSS calculations so you always get at least your normal padding:

An outlined notched phone on a dark blueprint grid. A full-bleed hero background runs edge to edge, including under the notch and the home indicator, which are marked as hatched inset-top and inset-bottom zones. The headline and Book a Consultation button stay inside a dashed safe rectangle.
With viewport-fit=cover, the hero can go edge to edge, but text and buttons need the safe-area insets so they don’t sit under the notch or the home bar.
/* Keep hero content clear of notches and the home bar */
.hero__content {
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

Sticky Buttons and the On-Screen Keyboard

A “Call Now” bar fixed to the bottom of the screen is a small-business favorite, and it’s a touch-friendly one when it’s done right. Give it the same safe-area treatment so it doesn’t sit on top of the home indicator:

/* Bottom call bar that respects the home indicator */
.call-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
}

The keyboard is a separate beast. It isn’t treated as browser toolbar UI, so it doesn’t change the viewport units by default. As the Chrome team explains, mobile browsers now generally shrink only the visual viewport when the keyboard opens, which means fixed elements stay put and can end up hidden behind it. If you want the layout itself to make room for the keyboard (say, a contact form with a fixed submit button), the interactive-widget key in the viewport meta tag lets you ask for that:

<!-- Ask the browser to resize the layout when the keyboard opens -->
<meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">

Treat it as a progressive enhancement. Chrome introduced it, support in other browsers is uneven (WebKit, the engine behind every iPhone browser, hasn’t traditionally honored it), and your form still needs to work fine when the keyboard simply covers the bottom of the screen.

What About the JavaScript –vh Hack?

Before these units existed, the standard trick was to measure window.innerHeight with JavaScript, stash it in a custom property and update it on every resize. It worked, mostly, at the cost of script running on every resize and a flash of the wrong size before it ran. Today it’s a legacy fallback at best. If you still need to support old browsers, only run it when svh is missing, and let CSS take over everywhere else:

// Legacy fallback only: skip it where svh is supported
if (!CSS.supports('height', '100svh')) {
  const setVh = () =>
    document.documentElement.style.setProperty('--vh', `${window.innerHeight * 0.01}px`);
  setVh();
  window.addEventListener('resize', setVh);
}
/* Legacy fallback first, modern unit wins where supported */
.hero {
  min-height: calc(var(--vh, 1vh) * 100);
  min-height: 100svh;
}

Pitfalls to Dodge

  • Trusting desktop dev tools. Responsive mode is great for media queries, but it doesn’t simulate retracting toolbars. Test on real phones, in more than one browser.
  • Reaching for dvh everywhere. It’s tempting because it’s “accurate,” but on scrolling content it means resizing and reflow while people read. Save it for overlays.
  • Forgetting landscape. A sideways phone has very little height. A min-height hero will grow to fit; a fixed height will overflow.
  • Using 100vw for full-bleed sections. Viewport units ignore scrollbars, so on systems with classic scrollbars, 100vw is a little too wide and causes horizontal scrolling. Use width: 100% instead.
  • Hard-coding toolbar heights. Browser makers keep redesigning their toolbars, with floating bars, translucent bars and pages that draw right behind them. Let the viewport units do the measuring so your layout keeps up without you chasing pixel values.
  • Making the hero do too much. If your headline, subhead, button and a carousel can’t fit on one small phone screen, the problem isn’t CSS. A focused hero is a better first impression anyway, and a lighter one helps with your page speed, too.

The Short Version

100vh measures the phone with its toolbars hidden, so your hero overflows on arrival. Use min-height: 100svh with a 100vh fallback for content that must be seen, lvh for backgrounds that must never gap, and dvh for overlays that don’t scroll. Add viewport-fit=cover and the safe-area insets if you go edge to edge, and test on a real phone with a real thumb.

If you’re planning a new custom website and want a hero that looks great on every screen without the toolbar eating your best button, let’s talk about your project.

Free, no-pressure quote

Let’s plan your site.

Pick what fits and the quote form takes it from there. It takes a few minutes, and you’ll usually hear back within a couple of business days.

Rather talk? Call or text (608) 448-6613

01 / 07
Project type

What are you looking for?

Pick one. You can press 1 to 5 on your keyboard.

Pick the option closest to your project.