Overview
Every responsive page needs <meta name="viewport" content="width=device-width, initial-scale=1">. Without it, mobile browsers lay the page out at a legacy width (about 980px) and zoom out. On mobile, the layout viewport and the visual viewport (the pinch-zoomed area) differ, and browser toolbars change the visible height.
Rules
- Do not add
user-scalable=noormaximum-scale=1; they block pinch zoom, which harms low-vision users. vwandvhsize against the layout viewport, and on mobilevhusually matches the large viewport with toolbars hidden, so100vhcan overflow. Usedvh(dynamic, tracks toolbars),svh(small, always fits), orlvh(large). All are supported in current browsers.- Use container queries for component sizing and viewport units for page-level layout (container-query).
.hero { min-height: 100dvh; }Related
- css-grid: page shells sized with viewport units.
- css-flexbox: full-height flex layouts.
- container-query: component-level responsiveness.
- css-units: unit reference.
- css: responsive conventions.
- html: where the meta tag lives.