Safe area inset environment variables
The safe-area-inset- CSS environment variables represent a rectangle that cannot cut off content within a non-rectangular screen. For example, top:\ env(safe-area-inset-top); positions the top of an element below the notch on an iPhone.
Overview
The safe-area-inset- CSS environment variables represent a rectangle that cannot cut off content within a non-rectangular screen. For example, top:\ env(safe-area-inset-top); positions the top of an element below the notch on an iPhone.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 69 | 79 | 65 | 11.1 | 69 | 11.3 | |
safe-area-inset-bottom Safe area inset variable `safe-area-inset-bottom` | 69 | 79 | 65 | 11 | 69 | 11 |
safe-area-inset-left Safe area inset variable `safe-area-inset-left` | 69 | 79 | 65 | 11 | 69 | 11 |
safe-area-inset-right Safe area inset variable `safe-area-inset-right` | 69 | 79 | 65 | 11 | 69 | 11 |
safe-area-inset-top Safe area inset variable `safe-area-inset-top` | 69 | 79 | 65 | 11 | 69 | 11 |
- This feature was removed in a later browser version (11.1)
- Previously available under a different name: constant (11)
- This feature was removed in a later browser version (11.3)
- Previously available under a different name: constant (11)
Syntax
body {
padding-top: env(safe-area-inset-top);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
} Live demo
Use cases
Using Safe area inset environment variables
The safe-area-inset- CSS environment variables represent a rectangle that cannot cut off content within a non-rectangular screen. For example, top:\ env(safe-area-inset-top); positions the top of an element below the notch on an iPhone.
Cautions
- May not be supported in older browsers.
Accessibility
- Make sure visual changes are conveyed appropriately to assistive technology.
Related links
- MDN Web Docs - Safe area inset environment variables
- Can I use - Safe area inset environment variables
Powered by web-features