HTML & CSS · Junior · Question 22 of 75
Which elements does z-index apply to?
- 1Any element, including
position: staticoutside flex and grid - 2Only elements with
display: blockand an explicit height - ✓Correct answer: Positioned elements, as well as flex and grid items
Explanation
z-index controls stacking order and applies to positioned elements and to children of flex/grid containers. On a regular static block outside flex/grid it is ignored. Remember stacking contexts: z-index: 9999 won't help if the parent sits in a "lower" context.