CSS z-index property
Example
Set the z-index of an image:
img
{
position:
absolute
;
left:
0
px
;
top:
0
px
;
z-index:
1
;
}
Try it »
Property definition and usage
The z-index property specifies the stacking order of an element.
An element with a higher stacking order is always in front of an element with a lower stacking order.
Note: z-index works on positioned elements (position:absolute, position:relative, or position:fixed).
| Default value: | auto |
|---|---|
| Inherited: | no |
| Version: | CSS2 |
| JavaScript syntax: | object.style.zIndex="1" |
Browser support
The numbers in the table indicate the first browser version that supports this property.
| property | |||||
|---|---|---|---|---|---|
| z-index | 1.0 | 4.0 | 3.0 | 1.0 | 4.0 |
Attribute values
| Value | Description |
|---|---|
| auto | Default. The stacking order is equal to the parent element's. |
| number | Sets the stacking order of the element. |
| inherit | Specifies that the z-index property should be inherited from the parent element. |
Related Articles
CSS Tutorial: CSS Positioning