CSS z-index Property
The z-index property sets the stack order of a positioned element and its descendants.
Description & Usage
The z-index property specifies 3D depth layering along the Z-axis for overlapping elements.
Elements with higher z-index values cover elements with lower values. It only applies to positioned elements (position relative, absolute, fixed, sticky) or flex/grid items.
Property Specifications
| Property Feature | Specification |
|---|---|
| Category | Layout |
| Initial Value | auto |
| Inherited | No (not inherited) |
| Applies To | Positioned elements and flex/grid items |
Syntax
z-index: auto | 1 | 10 | 1000;Property Values
| Value | Description |
|---|---|
| auto | Stack level matches parent stacking context. |
| 1000 | High stack priority, rendering above lower z-index siblings. |
Code Examples
Fixed Sticky Header Layer
.site-header {
position: sticky;
top: 0;
z-index: 100;
}
Ensures sticky navigation header stays on top of page content during scroll.