# Viewport Units

> The viewport units in CSS are relative length units based on the size of the viewport, including small, large and dynamic variants.

## Why is my 100vh taller than the screen on mobile?

The units relative to the viewport size, such as `vw` and `vh`. The `svh`, `lvh` and `dvh` variants take mobile browser toolbars into account: small, large or dynamic viewport. The `dvh` unit fixes the classic '100vh' overflow issue on mobile.

- Topic: Measurement Units
- Type: concept
- Browser support: Chrome 108+, Chrome Android 108+, Edge 108+, Firefox 101+, Firefox Android 101+, Safari 15.4+, Safari iOS 15.4+

## Example

Wrong:

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

Right:

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

The '100vh' line stays as a fallback, and `100dvh` follows the visible viewport where it is supported.

## Common mistakes

- `100vh` is taller than the visible area when the mobile browser toolbar shows.
- `width: 100vw` adds a horizontal scrollbar on desktop.

## Key points

- Full-height mobile sections use `dvh` or `svh` instead of `100vh`.
- Widths avoid `100vw`, which includes the scrollbar and causes horizontal scroll.
- Font sizes in `vw` are mixed with `rem` inside `clamp()`, so text still grows with user zoom.

## Interview questions

### What is the difference between svh, lvh and dvh?

`svh` uses the viewport with toolbars shown, `lvh` with toolbars hidden, and `dvh` changes between them as toolbars show and hide.

### Why does 100vw cause a horizontal scrollbar?

`100vw` includes the vertical scrollbar width, so an element with that width is wider than the page content area.

### Should I use dvh for everything?

No. `dvh` resizes while scrolling, which can cause jumps; use `svh` for layouts that must stay stable.

## Related cards

- [Container Query Units](https://wonderium.dev/css/container-query-units.md)
- [Relative Length Units](https://wonderium.dev/css/relative-length-units.md)
- [clamp()](https://wonderium.dev/css/clamp.md)
- [height](https://wonderium.dev/css/height.md)
- [env()](https://wonderium.dev/css/env.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/viewport-units
- Last updated: 2026-11-25
