Skip to content
ScreenMetricLab Check screen

Content cluster guide

Safe Area Insets for Mobile Layouts

Learn how CSS safe-area insets protect mobile UI from notches, rounded corners, home indicators, and dynamic browser viewport behavior.

Updated 2026-06-26 6 min read

What safe-area insets mean

Safe-area insets are CSS environment values such as env(safe-area-inset-top) and env(safe-area-inset-bottom). They represent extra spacing a layout may need so important controls are not hidden behind cutouts, rounded corners, home indicators, or browser UI edges.

Why values can be zero

A zero value does not always mean the checker is broken. Desktop browsers, rectangular screens, non-edge-to-edge pages, and some browser states can report zero because no extra safe padding is needed for the current viewport.

When to use viewport-fit cover

On iOS, edge-to-edge layouts commonly use a viewport meta tag with viewport-fit=cover. This allows the page to extend into the full display area while safe-area insets describe where content should avoid the edges.

How to test edge-safe UI

Test sticky bottom navigation, floating CTAs, chat inputs, headers, and full-screen panels on real mobile browsers. Pair safe-area measurements with visual viewport width, height, offsets, and dynamic viewport units.

Safe-area CSS examples

Combine safe-area values with normal spacing so desktop, Android, and iOS layouts all stay comfortable.

Edge-safe app shell

.app-shell {
  padding-top: max(16px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
}
UI elementSafe-area value to checkWhy it matters
Sticky headerTopAvoid notches and rounded top corners.
Bottom tab barBottomKeep controls above the home indicator.
Landscape side panelLeft / RightAvoid curved edges and camera cutouts.

Checklist

  • ✓ viewport-fit=cover reviewed for edge-to-edge pages
  • ✓ Top, right, bottom, and left insets checked
  • ✓ Sticky footer or bottom CTA tested
  • ✓ Landscape orientation tested
  • ✓ Visual viewport changes checked with browser chrome and keyboard
  • ✓ Fallback padding added for zero-inset browsers

Frequently asked questions

What does env(safe-area-inset-bottom) do?

It provides a CSS length that can be used to keep bottom fixed UI away from the home indicator or unsafe bottom edge on supported devices.

Why does desktop show 0px safe-area insets?

Most desktop browser windows do not have notches or home indicators, so zero values are expected.

Is safe-area the same as viewport height?

No. Safe-area insets describe edge padding, while viewport height describes the size of the visible or layout viewport.

Should I use safe-area values without base padding?

Usually no. Combine safe-area values with normal spacing, such as max(16px, env(safe-area-inset-bottom)), so layouts remain comfortable everywhere.