Building mobile-safe layouts with CSS safe-area-inset properties
By
Kilian Valkhof
Reliable enough to start your morning with. Toast it again tomorrow.
Summary
This article explains how to use CSS safe-area-inset properties to build mobile-friendly layouts that account for non-rectangular screen features like rounded corners, camera cutouts, dynamic islands, and home gesture indicators. It covers the concept of safe areas, how browsers expose these measurements via CSS environment variables (safe-area-inset-top, safe-area-inset-right, safe-area-inset-bottom, safe-area-inset-left), and provides practical techniques for applying padding, margins, and positioning to ensure content and interactive elements remain visible and accessible on modern mobile devices.
Key quotes
· 4 pulledThe 'safe area' is the portion of the screen that is guaranteed to be free from being obscured by system UI.
By using these values in your CSS, you can make sure that important content and controls are not obscured by the system UI.
Modern phones are not simple rectangles. They have rounded corners, camera cutouts, dynamic islands, and home indicators that double as gesture areas.
Browsers know the dimensions of all of these and expose the parts that could obscure content as safe area insets.
You might also wanna read
A developer's journey from Tailwind CSS back to vanilla CSS and semantic HTML
A developer reflects on their 8-year journey with Tailwind CSS, from initially embracing it as a solution to chaotic CSS to recently migrati
Recreating a retro multi-stroke text effect with CSS
A developer describes their journey trying to replicate a retro multi-stroke text effect using CSS. They initially struggled with the text-s
Modern CSS Reference: Comparing Outdated Techniques with Native CSS Replacements
modern-css.com is a reference website for web developers that provides side-by-side comparisons of outdated CSS techniques and their modern

Understanding CSS Stacking Contexts: How Elements Layer in Web Design
This article explains CSS stacking contexts - a fundamental CSS concept where elements are visually layered in three-dimensional space to cr
Safari Technology Preview 234 Introduces CSS Grid Lanes for Masonry Layouts
Safari Technology Preview 234 introduces CSS Grid Lanes, a new CSS Grid feature that enables masonry-style layouts. This allows content to b
CSS Grid Lanes: New Feature for Masonry Layouts Now Available in Safari Technology Preview
The article introduces CSS Grid Lanes, a new CSS feature for creating masonry layouts on the web. It explains that this technology has been
