The <meta name="viewport"> tag tells mobile browsers how to size and scale your page. Without it, phones emulate a large “virtual” desktop width and your layout looks tiny and zoomed out. The most common, safe value is:
<meta name="viewport" content="width=device-width, initial-scale=1">
This makes the layout width equal to the device screen width and loads the page at a natural 100% zoom, which is the foundation of responsive design on mobile devices.
width=device-width: Sets the layout viewport equal to the device width.initial-scale=1: Loads the page at 100% zoom (no automatic zoom-out).user-scalable=no or tiny maximum-scale.viewport-fit=cover is useful for full-bleed layouts on devices with notches.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Responsive Page</title>
</head>
width=device-width – the page width matches the device screen width instead of a fake desktop-sized viewport (e.g., ~980px).initial-scale=1 – initial zoom level. A value of 1 means “don’t zoom in or out” when loading.maximum-scale – upper zoom limit (avoid restricting it unless absolutely necessary).user-scalable – allows/disallows pinch zoom (don’t disable; it reduces accessibility).viewport-fit=cover – lets content extend into the notch / safe-area region.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Responsive Page</title>
<style>
.grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap:10px; }
.box { background:#4caf50; color:#fff; text-align:center; padding:16px; border-radius:6px; }
</style>
</head>
<body>
<div class="grid">
<div class="box">Box A</div>
<div class="box">Box B</div>
<div class="box">Box C</div>
</div>
</body>
</html>
Below is a simple responsive grid similar to the example above. Resize the window to see how the boxes wrap.
As you resize or rotate, these values update. With a correct viewport tag, they stay in sync with the real device width instead of an emulated desktop width.
width=device-width, initial-scale=1 as your default viewport settings.vw/vh/dvh).user-scalable=no or maximum-scale=1) — it harms accessibility.viewport-fit=cover and use env(safe-area-inset-*) in your CSS.width=600 and see how it breaks on small and very large screens.viewport-fit=cover and use padding: env(safe-area-inset-top) on a fixed header to handle devices with notches.dvh instead of vh and observe how it behaves when the mobile browser UI (address bar) shows/hides.width=device-width, initial-scale=1 is the standard, accessible default.viewport-fit=cover help polish experiences on modern phones with notches.