What is Z-Index?

Z-index is a CSS property that allows you to specify the order of elements that are stacked on top of each other. It is a number that is used to determine the relative position of a given element compared to the other elements. The higher the number, the higher the element will be in the stacking order.

How Z-Index Works

The Z-index property works by assigning a number to an element that determines its relative position compared to other elements in the same stack. If two elements have the same Z-index value, the element that is defined last will be the one that appears on top. Elements with higher z-index values will always appear on top of elements with lower z-index values.


Let’s look at an example to better understand how Z-index works. Imagine you have two elements, a

and a

, that are both positioned on the same plane. The

element has a z-index value of 5 and the

element has a z-index value of 3. In this case, the

will appear on top of the

element, since it has the higher z-index value.


The Z-index property is an important tool to use when designing webpages. It allows you to control the order of elements and ensure that the desired elements are always displayed on top. For more information on Z-index, see the following links: