Full answer
On many phones the browser toolbar and address bar slide away when the user scrolls down, and return when they scroll up. The visible area of the page grows and shrinks. The classic vh unit was defined as a fixed size, as if the toolbars were hidden. So 100vh can be taller than the visible area when the toolbar is shown, and a bottom button or footer sized with it goes below the visible edge.
Newer viewport units cover the cases:
lvhis the large viewport: the size when the toolbars are retracted. Plainvhmatches this.svhis the small viewport: the size when the toolbars are fully shown. It is always fully visible.dvhis the dynamic viewport: it follows the real visible size and changes as the toolbars move.
There are matching width and logical units (dvw, dvi, dvb and so on), though height is where the problem is.
How to choose:
- A full-screen hero or a modal sheet that must always fit on screen: use
svhfor a safe size, ordvhfor an exact fit. - A layout that should fill the screen but where a small change is acceptable:
dvh. Note that it can cause layout changes while scrolling, so avoid it for large areas that cause reflow on every scroll. - When the toolbar behaviour does not matter:
vhis fine.
Unsupported browsers ignore a declaration with an unknown unit, so write the old value first, then the new one. Also check the support table. On desktop, all three equal the window height, because there is no sliding toolbar.
On a desktop browser, the hero is exactly as tall as the window, because small, large and dynamic sizes are the same there. On a phone, the hero is as tall as the area visible when the address bar is shown, and the sheet follows the visible size as the toolbar moves.
The phone behaviour is not shown by this example. Test it on real devices or in a device emulator with the browser toolbar visible.
<style>
html, body { margin: 0; }
.hero { height: 100vh; height: 100svh; background: #cde; }
.sheet { height: 50vh; height: 50dvh; background: #fdc; }
.tall { height: 100lvh; background: #dfc; }
</style>
<div class="hero" id="hero">Always fits with toolbars shown</div>
<div class="sheet" id="sheet">Half of the visible height</div>
<div class="tall" id="tall">Large viewport height</div>Checked on a desktop viewport, where the three units give the same height. The sliding toolbar on phones was not tested. Run in Chrome 156 (headless) as a page; the snippet is wrapped in a minimal HTML document with doctype, charset and viewport meta tag. Two full runs gave identical results, and the measured values in the answer come from them.
Key points
- vh behaves like the large viewport on many phones.
- svh is the smallest visible height; lvh is the largest.
- dvh follows the visible height as toolbars move.
- On desktop all three are equal.
- Write a vh fallback before the newer unit.
Common mistakes
- Using 100vh for a full-screen mobile layout and finding the bottom button hidden under the toolbar.
- Using dvh for large areas that must not resize while the user scrolls.
- Using the new units with no fallback line for older browsers.
Follow-ups
- Which unit is the same as the old vh?
- Why write the 100vh line before the 100svh line?
Tips
- Define the three units in one line each: large, small, dynamic.
- Say that on desktop they are equal, and the difference only appears on mobile browsers with moving toolbars.