CSS Basic Tutorial
CSS Flexbox
The z-index
property in CSS controls the stacking order of elements along the z-axis (i.e., front-to-back order). It determines which elements appear in front of or behind other elements on the page.
z-index: <value>;
Value:Positive, negative, or 0
(e.g., 1
, 100
, -1
).
Try it yourself
Rule of using Z-index
The element must have a position
value of:relative
,absolute
,fixed
,sticky
Elements with a higher z-index
will appear in front of elements with a lower z-index
.