CKTIS / CSS
vh — viewport height unit
The CSS unit vh represents 1% of the large viewport height. It makes a length depend on the browser viewport rather than the size of a parent element.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
<number>vhvh is a relative CSS length unit: 1vh represents 1% of the large viewport height, and 100vh its full height. Write the number immediately before the unit, without a space, for example 50vh. The unit refers to physical height regardless of writing direction.
The large viewport assumes that expandable and retractable browser controls are retracted. Consequently, vh corresponds to lvh, and an element with a height of 100vh can be partly obscured by visible browser controls on a phone. svh refers to the small viewport, while dvh accounts for changing controls and can cause resizing during scrolling.
height: 50vh does not mean half the parent's height; percentage height uses a different reference. In the example, the panel is 400 CSS pixels high when the large viewport height is 800 CSS pixels. Changing that viewport height to 600 CSS pixels produces a panel height of 300 CSS pixels.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>vh example</title>
<style>
html, body { margin: 0; }
.panel {
height: 50vh;
background: #bde0fe;
}
</style>
<div class="panel">50vh</div>
</html>Result
A blue panel with the text "50vh". Its height is 50% of the large viewport height: 400 CSS px when that viewport height is 800 CSS px.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.