Easy Tutorial
❮ Prop Canvas Textalign Prop Audio Audiotracks ❯

Style zIndex Property


Definition and Usage

The zIndex property sets or returns the stack order of positioned elements.

An element with a higher stack order (1) will always be in front of an element with a lower stack order (0).

Tip: A positioned element is one whose position property is set to: relative, absolute, or fixed.

Syntax

Set the zIndex property:

Return the zIndex property:

Value Description
auto Default. The browser decides the stack order of the element (based on its order in the document).
number An integer that defines the stack order of the element. Negative values are allowed.
inherit The zIndex property value is inherited from the parent element.

Browser Support

All major browsers support the zIndex property.


Tips and Notes

Tip: This property is very useful if you want to create overlapping elements.


Example

Change the stack order of an <img> element:

❮ Prop Canvas Textalign Prop Audio Audiotracks ❯