Skip to the page
css reference · display & flow

CSS z-index

type
property
applies to
a positioned element (anything with position other than static)
inherits
no
common values
auto (default), 0, 10, 100, -1

Where it goes

On the same box as its position rule, whenever that box must sit above or below something it overlaps.

Example

.dropdown {
  position: absolute;
  z-index: 10;
}
.modal-overlay {
  position: fixed;
  z-index: 100;
}

Common mistakes

  • Setting z-index on a box with no position. Nothing happens, and it is easy to miss why.
  • Reaching for bigger and bigger numbers (999, 9999) to win a fight. That is a sign two parts of the page are using the same range with no plan. Find the real order instead.

Related

Updated 24 October 2026. Practice it in the css route, or read more on MDN.