New! My 44-page ebook "CSS in 44 minutes" is out! 😃

Get it now →

#z-index

Defines the order of the elements on the z-axis. It only works on positioned elements (anything apart from static).

default z-index: auto;

The order is defined by the order in the HTML code:

  • first in the code = behind
  • last in the code = in front

z-index: 1;

The z-index value is relative to the other ones. The target element is move in front of its siblings.

z-index: -1;

You can use negative values. The target element is move in behind its siblings.