The z-index property decides order in which the elements are displayed in the web page. This property is useful to create layers for the document. This property gives the third dimension to the element. The element having z-index property will be displayed above or in background of other element.
There are two values for the z-index auto and “numeric value” or order. The higher the numeric value the more the element is on the top of the other element. Lower(negative also) the value more element is displayed behind the other elements.
This property works with position property.
Following is the code example of the z-index property:
Following is the output of the above code:
Now here you can see the red box is above the green box. This is because the z-index property of the element is set to 10.