z-index represents the order on the z-plane in which an element appears. An element with higher stack order is always in front of another element with lower stack order. It is available in most of the GUI frameworks (both Web and Desktop).
In CSS
z-index is a CSS property that sets the stack order of specific elements. An element with greater stack order is always in front of another element with lower stack order.
p {
position: relative;
z-index: -1;
}
This paragraph will be positioned behind the rest of the page, as long as the rest of the page has z-index: 0
, which is specified by default.
Negative stack orders can also be used in the same manner. A negative value will appear behind a more positive one. z-index only works on elements that have a position value (i.e. position: relative;). Like all other CSS properties, it can be set with javascript as well with the following syntax:
object.style.zIndex = "1";
In WPF
Panel.ZIndex Attached Property
In Silverlight
Canvas.ZIndex Attached Property
See also z-order regarding the general concept.