DEV Community

Mahalakshmi C
Mahalakshmi C

Posted on

CSS z-index

CSS z-index

  • The z-index property in CSS is used to control the stacking order of elements on a web page.
  • It determines which element appears in front of or behind another element when they overlap.

  • Elements with a higher z-index value appear above elements with a lower z-index value.

Syntax

selector {
    z-index: value;
}
Enter fullscreen mode Exit fullscreen mode

Important points

  • The z-index property works only with positioned elements.
  • It can be used with relative, absolute, fixed, and sticky positions.
  • Positive values move elements forward.
  • Negative values move elements behind other elements.

Top comments (0)