CSS viewport units size an element against the viewport of the document—not its parent. For mobile layouts, choose svh when the element should fit the smaller viewport with browser controls visible, lvh when it should target the largest viewport, or dvh when it should track the current viewport as browser controls change. The legacy vh unit maps to the large viewport height, which can make a full-height element extend below the currently visible area.
What viewport units measure
A viewport unit is a length based on a dimension of the viewport. It is not a percentage of the element’s parent. For example, 1vw is one percent of the viewport width, and 1vh is one percent of its height. The CSS Values and Units Module Level 4 defines the unit families and their relationships.
The viewport is the one belonging to the document being styled. In an iframe, viewport units refer to that iframe document’s viewport; they do not automatically refer to the top-level browser viewport.
How vh, svh, lvh, and dvh differ
On mobile, browser controls can expand and retract as a person scrolls. That changes the available visible area. The newer height units express which viewport state a layout should use:
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match#1 Best Overall
| Unit | Viewport reference | How it behaves as browser controls change | Good fit when |
|---|---|---|---|
svh |
Small viewport, with retractable browser interface expanded | Represents the more constrained viewport size | A region should fit within the viewport while the browser interface is present |
lvh |
Large viewport, with retractable browser interface retracted | Represents the maximum viewport size | The design is intended to use the largest available viewport |
dvh |
Dynamic viewport | Can change as browser interface changes | An element should follow the current viewport size |
vh |
Maps to the large viewport height, equivalent to lvh |
Does not mean the currently visible height when browser controls are expanded | Existing styles rely on the legacy large-viewport interpretation |
The specification explains the legacy mapping this way: “However at this point the mapping to the large viewport-percentage units is presumed to be required for Web compatibility.”
Choose a unit for the layout you want
Keep a hero or panel within the constrained viewport
Use a minimum height such as min-height: 100svh when a section should fit the smaller viewport state. Prefer min-height for content that may need more than one screen; a fixed height can leave too little room for content that grows.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Follow the currently available height
Use height: 100dvh when the element should match the dynamic viewport as browser controls expand or retract. Because the unit can change with that interface, check the result on the browsers and devices that matter to your project.
Target the maximum available height
Use 100lvh when the intended reference is the largest viewport. Be aware that this is also the interpretation used by 100vh; with browser controls expanded, that height may extend beyond the visible area.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
Other viewport unit families
Viewport units are not limited to physical width and height. Select the family that matches the dimension your layout actually depends on:
vwandvhuse viewport width and height.viandvbuse the logical inline and block dimensions, which follow the writing mode rather than assuming width and height are the relevant axes.vminandvmaxuse the smaller and larger viewport dimensions, respectively.- The small, large, and dynamic variants also apply across the corresponding viewport-unit families, including width and logical-axis forms.
Use logical units when the design should adapt to writing direction and mode. Use minimum- or maximum-dimension units only when the smaller or larger viewport dimension is genuinely the reference you need.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Validate the result on the devices you support
Viewport sizing is only one part of layout. Content height, overflow rules, and surrounding layout also affect whether a section fits or clips. The unit definitions describe the viewport reference; they do not guarantee a particular rendered result across every browser. Check the layout at relevant screen sizes, including while mobile browser controls are expanded and retracted.
For repeatable visual checks, a screenshot can help compare a page’s rendered appearance. ScreenshotNeo is a website screenshot API and MCP server, but an automated capture is not a substitute for checking the actual browser behavior you need to support.
Best Value
Or skip the browser setup
To capture a page for visual review, make a GET request with its URL:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for API options. Cookie banners, newsletter popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo free.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

