You are here: Home / Topics / What is the purpose of the z-index and how is it used?

What is the purpose of the z-index and how is it used?

Filed under: CSS Interview Questions on 2022-07-02 15:20:55

The z-index helps specify the stack order of positioned elements that may overlap one another. The z-index default value is zero, and can take on either a positive or negative number.

An element with a higher z-index is always stacked above than a lower index.

Z-Index can take the following values:

  • Auto: Sets the stack order equal to its parents.
  • Number: Orders the stack order.
  • Initial: Sets this property to its default value (0).
  • Inherit: Inherits this property from its parent element.
About Author:
D
Dharmendra Sir     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.