Every element in an HTML document can be either in front of or behind every other element in the document
Stacking order is the same as the order of appearance in the HTML
Any positioned elements (and their children) are displayed in front of any non-positioned elements.
things get a little trickier
z-index creates stacking context
A three-dimensional conceptualization of HTML elements along imaginary z-axis relative to the user,
Groups of elements with a common parent that move forward or backward together in the stacking order
<div><!-- 1 -->
<span class="red"><!-- 6 --></span>
</div>
<div><!-- 2 -->
<span class="green"><!-- 4 --><span>
</div>
<div><!-- 3 -->
<span class="blue"><!-- 5 --></span>
</div>
<div><!-- 1 -->
<span class="red"><!-- 1.1 --></span>
</div>
<div><!-- 2 -->
<span class="green"><!-- 4 --><span>
</div>
<div><!-- 3 -->
<span class="blue"><!-- 5 --></span>
</div>