CSS Tutorial

The language for styling web pages.

CSS Z-index

CSS Z-index

The z-index property specifies the stack order of an element (which element is in front of or behind the others). It only works on positioned elements (position: absolute, relative, fixed, or sticky).

Rules:

  • Higher z-index = in front
  • Default z-index is auto (0)
  • Can be negative
  • Only works with position set

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics