---
title: "Why is 100vh too tall on mobile? Use svh, lvh and dvh"
description: "On mobile, 100vh includes space hidden behind the browser toolbar, so full-height layouts overflow. The svh, lvh and dvh viewport units fix this. Here is when to use each."
url: https://www.danny.engineering/answer/css/why-is-100vh-too-tall-on-mobile-use-svh-lvh-and-dvh
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T17:25:00.000Z
tags: ["CSS"]
---

# Why is 100vh too tall on mobile? Use svh, lvh and dvh

## The short answer


On mobile browsers, `100vh` is measured as if the address bar and toolbars were hidden, so it is taller than the visible screen when they are showing. Use the newer viewport units instead: `100svh` for the smallest visible height, or `100dvh` to track the toolbar as it moves.


```css
.hero {
  min-height: 100vh;  /* fallback for very old browsers */
  min-height: 100svh;
}
```


## Why it happens


Mobile browsers show and hide their address bar and toolbar as you scroll. If `vh` changed every time that happened, every element sized with it would resize mid-scroll, causing jank and layout shifts. So browsers chose to keep `vh` fixed at the **largest** possible viewport height, the one you get when the toolbars are retracted.


When the page first loads, the toolbars are usually visible. A `100vh` section is then taller than the space on screen, and the bottom of it, often a call to action button, is hidden behind the browser chrome.


The CSS Values and Units specification added three sets of units to make the choice explicit:


| Unit  | Means                                   | Changes on scroll? |
| ----- | --------------------------------------- | ------------------ |
| `svh` | small viewport height, toolbars showing | No                 |
| `lvh` | large viewport height, toolbars hidden  | No                 |
| `dvh` | dynamic, whichever is current           | Yes                |


There are matching width units (`svw`, `lvw`, `dvw`) and logical versions (`svb`, `svi` and so on). These units are supported in all current major browsers and have been for several years.


## How to fix it


### Use svh for full-screen sections


For a hero or splash section that should fit on screen when the page first loads, `svh` is the safest choice. It never changes while scrolling, so nothing jumps.


```css
.hero {
  min-height: 100svh;
}
```


The trade-off is a small gap at the bottom once the toolbar retracts. For most layouts that is fine.


### Use dvh for app shells and fixed panels


If you are building an app-like layout where a footer or input bar must always sit at the very bottom of the visible area, `dvh` follows the real height:


```css
.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
```


Because `dvh` changes while the user scrolls, avoid it on long, content-heavy pages. Resizing large areas during scroll can be expensive and visibly jumpy.


### Keep a vh fallback if you need it


Browsers ignore declarations they do not understand, so listing `vh` first and the new unit second gives older browsers a reasonable fallback:


```css
.panel {
  height: 100vh;
  height: 100dvh;
}
```


### Drop the JavaScript workaround


Before these units existed, a common fix was to measure `window.innerHeight` and store it in a custom property:


```javascript
// Old workaround: no longer needed in current browsers
const setVh = () => {
  document.documentElement.style.setProperty('--vh', `${window.innerHeight * 0.01}px`);
};
window.addEventListener('resize', setVh);
setVh();
```


You can remove this and use `svh` or `dvh` instead. It runs on every resize and can still be out of step with the toolbar.


## Common pitfalls

- **Using** **`height`** **where** **`min-height`** **is better.** A fixed `height: 100svh` cuts off content on short screens or with large text. Prefer `min-height` unless the layout must be exactly one screen.
- **Reaching for** **`dvh`** **everywhere.** It is the most accurate but also the only one that moves. Start with `svh`.
- **Forgetting the on-screen keyboard.** By default, the virtual keyboard does not resize these units in most mobile browsers. Look at the `interactive-widget` key in the viewport meta tag if you need the layout to respond to it.
- **Expecting a difference on desktop.** On desktop browsers without retracting toolbars, all three units are the same as `vh`.

## Related reading

- [MDN: length units, relative to the viewport](https://developer.mozilla.org/en-US/docs/Web/CSS/length#relative_length_units_based_on_viewport)
