The z-index property is used in CSS and certain HTML elements. It specifies the z-order of an element and its descendants. When elements overlap, z-order determines which one covers the other. An element with a larger z-index generally covers an element with a lower one.
For a positioned box, the z-index property specifies:
- The stack level of the box in the current stacking context.
- Whether the box establishes a local stacking context.
Values
auto- The box does not establish a new local stacking context. The stack level of the generated box in the current stacking context is the same as its parent's box.<integer>- This integer is the stack level of the generated box in the current stacking context. The box also establishes a local stacking context in which its stack level is0. This means that the z-indexes of descendants are not compared to the z-indexes of elements outside this element.