Safe Areas and Notches: Using env(safe-area-inset-*)
By Pritesh Ranoliya · Updated
By default, mobile browsers keep your page inside the safe area, so notches and rounded corners don’t cover it. If you opt into drawing edge to edge with viewport-fit=cover, you must pad the edges yourself with env(safe-area-inset-top), -right, -bottom and -left, which report how much of each edge is covered by a notch, camera cutout, rounded corner or the home indicator.
When you need it
You only need safe-area insets if the page draws to the very edges:
- a full-bleed header or background colour that should reach behind the notch,
- a fixed bottom bar that must sit above the home indicator,
- landscape layouts, where the notch moves to the left or right edge.
Without viewport-fit=cover, the browser letterboxes the page into the safe area and the insets are zero.
Step 1: opt in
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
Step 2: pad the edges
.site-header {
padding-top: env(safe-area-inset-top);
}
.bottom-bar {
position: fixed;
inset-inline: 0;
bottom: 0;
padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.page {
padding-left: max(16px, env(safe-area-inset-left));
padding-right: max(16px, env(safe-area-inset-right));
}
max() keeps your normal spacing on devices without a notch, where the inset is 0, and grows it where the cutout is bigger (MDN).
Which devices it affects
- Notch and Dynamic Island iPhones report a top inset in portrait and side insets in landscape, plus a bottom inset for the home indicator. Examples: iPhone 14 (notch) and iPhone 16 Pro (island).
- Android phones with a punch-hole camera report a cutout inset when the page is drawn edge to edge, for example the Pixel 9.
- Phones with bezels, such as the iPhone SE (3rd gen), report zero.
Test it
Rotate to landscape on a notch iPhone: that is where left and right insets matter and where most bugs hide. The Mobile Simulator draws generic notch, island and punch-hole frames so you can see how close content runs to each cutout; confirm the final spacing on a real phone, because only the device reports the real inset values.