A new stacking context is created when an element is positioned (relative, absolute, fixed, sticky) and has a z-index value other than auto. Option D has position: absolute and z-index: 0, which creates a new stacking context.
Option D has z-index: auto, so no new stacking context. Option D with opacity: 1 does not create stacking context. Option D does not create stacking context.
Option C creates a stacking context because position: fixed with a z-index value creates a new stacking context.
Option C has position: static, so z-index is ignored and no stacking context is created.
Option C with opacity: 1 does not create stacking context (opacity less than 1 does).
Option C with display: flex does not create stacking context by itself.
HTML: <div class="parent"> <div class="child1">Child 1</div> <div class="child2">Child 2</div> </div> CSS: .parent { position: relative; z-index: 1; background: lightblue; width: 200px; height: 200px; } .child1 { position: relative; z-index: 2; background: coral; width: 100px; height: 100px; margin: 20px; } .child2 { position: relative; z-index: 1; background: lightgreen; width: 100px; height: 100px; margin: 50px; }
The parent has position: relative and z-index: 1, creating a stacking context. Inside it, child1 has z-index: 2 and child2 has z-index: 1. Since both children are in the same stacking context, child1 with higher z-index appears on top.
Option B matches elements with opacity 0.99, which is less than 1, so these elements create stacking contexts due to opacity.
Option B matches any opacity but does not guarantee less than 1. Options C and D match other specific values less than 1, but B is the selector for opacity: 0.99 as example.
Stacking context controls visual layering, not the order of keyboard navigation. Keyboard navigation follows the DOM order or tabindex attributes. However, stacking context can affect how visible the focus outline is, impacting accessibility.
Options B, C, and D incorrectly link stacking context to keyboard focus order or screen reader behavior.