Skip to main content
InterviewHubPRO
Section Overview
Q16

Question 16 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

32%
CSS3 & Modern Layouts (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What is a Stacking Context and why does `z-index: 99999` sometimes fail?

senior LevelMost AskedMemory ManagementSystem DesignData Structures

In Simple Words: z-index only controls stacking order within the same Stacking Context. An element with z-index: 99999 will still render behind an element with z-index: 1 if its parent container is trapped in a lower stacking context!

What Creates a New Stacking Context:

  1. Root element (<html>).
  2. Positioned elements (relative, absolute, fixed, sticky) with z-index other than auto.
  3. Elements with opacity less than 1.
  4. Elements with transform, filter, perspective, or clip-path.
  5. Elements with isolation: isolate (The modern, clean way to contain stacking contexts!).
  6. Elements with container-type.