
Viewport Meta and Safe Areas: Handling Device Chrome
The viewport meta tag controls layout sizing; env(safe-area-inset-*) describes where notches, cutouts, and home indicators intrude. Edge-to-edge layouts need both.
TL;DR: The viewport meta tag controls how the browser sizes the layout viewport, and env(safe-area-inset-*) describes where device chrome — notches, hole punches, rounded corners, home indicators — intrudes on that viewport. Edge-to-edge layouts need both. The canonical declaration is <meta name="viewport" content="width=device-width, initial-scale=1">, with viewport-fit=cover added when the page renders edge-to-edge. Safe-area inset variables reached Baseline 2020 (Widely available since July 2022, as of Nov 2026, per web-features) and return zero where no chrome intrudes; for fixed bottom bars, Chrome's guidance for Chrome 135 and later on Android recommends a different pattern, covered below. Do not use user-scalable=no — it blocks pinch zoom in browsers that honor it, and the W3C conformance test rule for WCAG 1.4.4 Resize text fails it, although a page may still satisfy 1.4.4 in the cases described below.
Two separate concerns: viewport scaling and safe area
Mobile browsers maintain two viewports. The layout viewport is the rectangle the page lays out into; the visual viewport is the slice of that layout currently visible to the user, which can be smaller during pinch zoom or with the keyboard open. The viewport meta tag controls the layout viewport's initial size and scale.
Device chrome is a separate concept. It is the area of the physical screen occupied by hardware features — the notch on an iPhone, the hole punch on a Samsung, the rounded screen corners, the iOS home indicator gesture bar at the bottom — that the browser knows the page should not render content under because the user cannot reliably see or tap it. The safe-area inset variables expose those keep-out regions to CSS.
These answer different questions. "How large is the viewport, and how is content scaled to fit it?" is the viewport meta tag's job. "Where in the viewport are the keep-out zones?" is the safe-area inset's job. Edge-to-edge layouts — the kind that benefit from viewport-fit=cover — need both, because they are exactly the ones that crash into device chrome without inset padding.
Viewport meta: the canonical declaration
The canonical viewport meta tag is short and has remained stable for over a decade:
<meta name="viewport" content="width=device-width, initial-scale=1">width=device-width sets the layout viewport width to match the device width in CSS pixels — the device-pixel-ratio adjusted abstraction that makes a 320 CSS pixel layout render at the correct physical size on a 640-physical-pixel phone. Without this, mobile browsers generally fall back to a desktop-width viewport (typically 980 to 1024 pixels) and scale it down, which is how non-mobile-aware sites end up rendering tiny on phones.
initial-scale=1 sets the initial zoom level so the layout renders 1:1 with the CSS pixel size. Use this exact pair unless the page has a specific reason not to. The MDN viewport meta tag reference has the full attribute catalog.
viewport-fit=cover is the addition that activates edge-to-edge rendering on iOS Safari and lets the page lay out to the full size of the screen. Without it, Safari insets the page within the display's safe area, so it is not obscured by the rounded corners or the sensor housing, and fills the inset area with the page's background color. Sites with full-width navigation bars, a full-bleed hero, or edge-to-edge images can opt into viewport-fit=cover to run those elements to the screen edge; WebKit notes that for many websites the default insetting is enough, for example pages with only text and images above a solid background color.
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">Two attributes are accessibility regressions and should not appear in any production viewport meta tag. user-scalable=no blocks pinch zoom in browsers and web views that honor it. maximum-scale=1 (or any value below 2) blocks zooming to 200 percent in browsers that honor it. WCAG 1.4.4 Resize text, a Level AA success criterion, requires that, except for captions and images of text, text can be resized without assistive technology up to 200 percent without loss of content or functionality. The W3C Understanding document adds that content satisfies the criterion if it can be scaled up to 200 percent using at least one text-scaling mechanism supported by user agents. The W3C conformance test rule for 1.4.4, ACT rule b4f0c3 "Meta viewport allows for zoom", fails a viewport meta that has user-scalable=no or a maximum-scale value below 2. The same rule notes that a page may still satisfy 1.4.4 and 1.4.10 Reflow despite that failed result if the page has no visible content, if another mechanism is available to resize the text content, or if the content does not need to reflow to fit an area of 320 by 256 CSS pixels. Users with low vision, users on devices in transit, users who have temporarily smudged their glasses — all of them rely on pinch zoom. When the viewport meta sits in a shared template, a blocking value reaches every page that uses the template. Browser behavior varies: the ACT rule notes that desktop browsers ignore the viewport meta element and that most modern mobile browsers either ignore it by default or have an accessibility option that allows zooming, and Safari on iOS has ignored user-scalable, minimum-scale, and maximum-scale for pinch zoom since iOS 10, although apps embedding WKWebView still honor user-scalable by default. Other browsers and in-app web views can still enforce them, so remove the declaration rather than treating it as a harmless no-op.
Safe area inset env() variables
The env() CSS function exposes a set of user-agent-defined values. The safe-area inset variables — safe-area-inset-top, safe-area-inset-right, safe-area-inset-bottom, safe-area-inset-left — are the ones this article uses. The W3C CSS Environment Variables Module Level 1 is the spec; the MDN env() reference has practical examples. The variables reached Baseline 2020, when they became supported in all of the core browsers, and have been Baseline Widely available since July 2022 (as of Nov 2026, per web-features).
Each returns the CSS pixel size of the chrome inset on that edge of the viewport. On an iPhone with a notch held in portrait, safe-area-inset-top reserves room for the notch, and the exact value varies by model; rotated to landscape, the side inset on the sensor-housing side (safe-area-inset-left or safe-area-inset-right, depending on the direction of rotation) rises to inset around the notch. On a device without chrome on that edge — or on desktop — the variable returns zero. Where the variable is zero, the max() pattern below keeps the design padding.
Pair the inset with max() or calc() so the design padding stays intact when the inset is zero and grows when chrome is present:
.fixed-top-bar {
position: fixed;
inset-block-start: 0;
inline-size: 100%;
padding-block-start: max(1rem, env(safe-area-inset-top));
/* safe-area insets are physical: pair them with physical padding */
padding-left: max(1rem, env(safe-area-inset-left));
padding-right: max(1rem, env(safe-area-inset-right));
}
.fixed-bottom-bar {
position: fixed;
inset-block-end: 0;
inline-size: 100%;
padding-block-end: max(1rem, env(safe-area-inset-bottom));
}The max() ensures the visual padding is at least the design value (1rem here) and grows when device chrome demands more. The side padding (padding-left and padding-right) matters in landscape orientation, where notches and rounded corners intrude from the sides rather than the top. The safe-area variables are physical (top, right, bottom, left), so they pair with physical padding; the block-axis declarations in these examples assume a horizontal writing mode, where block-start is the top.
A common mistake is treating safe-area insets as iOS-only. Android browsers support the same variables; from Chrome 135, for example, Chrome on Android small-screen devices lets the viewport extend into the gesture navigation bar area when its toolbars retract (or from page load, for pages that opt in with viewport-fit=cover), and the safe area insets mark where content would be obstructed by that bar (as of Nov 2026). The variable is the API; the values depend on the device and the browser.
Common application patterns
This section covers three patterns.
Fixed top navigation that floats above content with position: fixed needs padding-top that combines design padding with safe-area-inset-top. Without it, the brand mark or title row renders under the notch on iPhones.
Fixed bottom navigation — tab bars, action toolbars, sticky CTAs — needs padding-bottom combined with safe-area-inset-bottom. The iOS home indicator gesture bar sits at the bottom of every iPhone in the post-home-button era. WebKit's guidance for websites is to keep important content clear of the indicator for accessing the Home screen, as well as the rounded corners and the sensor housing. The inset moves the tappable area above the gesture region. Chrome on Android is different: from Chrome 135 on small-screen devices, Chrome's edge-to-edge migration guide advises against padding a fixed bottom element with env(safe-area-inset-bottom), because that inset changes as Chrome's bottom bar (the "chin") moves out of the way, and the padding then causes layout thrashing. It recommends growing the element with safe-area-max-inset-bottom and offsetting bottom by env(safe-area-inset-bottom) minus that maximum instead (as of Nov 2026).
Edge-to-edge hero sections — a full-bleed image or color block running the entire viewport width — work fine in portrait but need padding-left and padding-right matching safe-area-inset-left and safe-area-inset-right in landscape, so the content inside the hero does not slide under the rotated notch.
Dynamic viewport units complement safe area
Safe area insets and dynamic viewport units solve different parts of the same edge-to-edge problem. The dynamic viewport units — dvh, svh, lvh — reached Baseline 2022 and handle the iOS Safari toolbar resize that breaks 100vh layouts. 100dvh tracks the viewport as the browser's retractable toolbars show and hide (browsers are not required to update it during the toolbar animation, and an on-screen keyboard typically overlays the page without changing it); 100svh is the smallest possible visible viewport (toolbar showing); 100lvh is the largest (toolbar hidden).
For full-page layouts, the right combination is min-height: 100svh for the smallest reliable footprint plus safe-area-inset padding for the chrome inset:
.full-page-section {
min-block-size: 100svh;
padding-block-end: max(1rem, env(safe-area-inset-bottom));
}The dynamic units handle the toolbar resize; the safe-area inset handles the home indicator. Together they keep the content clear of the retractable toolbars and the home indicator; an on-screen keyboard can still overlay it.
Phase 1 deliverables and acceptance criteria
The audit is short.
- Add
viewport-fit=coverto the viewport meta tag if the site has full-width navigation bars, a full-bleed hero, or other content that should render edge to edge. Without it, Safari on iOS insets the page within the safe area and fills the inset area with the page's background color. - Pair the
env(safe-area-inset-*)padding onposition: fixedelements withmax(). For fixed bottom bars on Chrome for Android (Chrome 135 and later, small-screen devices), Chrome's edge-to-edge guide recommendssafe-area-max-inset-bottompadding with abottomoffset instead, because padding that tracks the dynamic inset causes layout thrashing there (as of Nov 2026). - Test on an iPhone with a notch in portrait and landscape, an Android with a hole-punch cutout, and an iPad. All three behave differently, so check each one, on real hardware or a simulator.
- Remove any
user-scalable=noormaximum-scale=1from the viewport meta. The W3C conformance test rule for WCAG 1.4.4 Resize text fails both (a page may still satisfy 1.4.4 in the cases described above), and a value in a shared template reaches every page that uses it. - Combine
100svhwithenv(safe-area-inset-bottom)for full-page layouts that include fixed bottom UI. The two declarations together handle both the toolbar resize and the home indicator inset.
Missing one of these where it applies — for example the bottom inset on a fixed tab bar after opting into viewport-fit=cover — produces a layout that looks broken on the device, not on the developer's monitor.