CSS z-index Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The z-index CSS property specifies the layering or stacking order for the positioned elements i.e. elements whose position value is one of absolute, fixed, or relative. The stacking order refers to the position of elements along the Z-axis which is perpendicular to the screen.
The following table summarizes the usages context and the version history of this property.
| Default value: | auto |
|---|---|
| Applies to: | Positioned elements |
| Inherited: | No |
| Animatable: | Yes. See animatable properties. |
| Version: | CSS 2, 3 |
Note: When elements overlap, z-index determines which one overlaps the other. An element with a higher z-index generally overlaps an element with a lower one.
Syntax
The syntax of the property is given with:
The example below shows the z-index property in action.
Example
Try this code »div {
position: absolute;
lop: 30px;
left: 30px;
z-index: 2;
}
Property Values
The following table describes the values of this property.
| Value | Description |
|---|---|
| integer | Sets the stack level of the element's box in the current stacking context. The box also establishes a local stacking context in which its stack level is 0 (zero). Negative integer values are allowed. |
auto |
The stack level of the element's box is the same as its parent's box, and doesn't establish a new stacking context. This is default value. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element z-index property. |
Browser Compatibility
The z-index property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS Position, CSS Layers.

