CSS positioning and z-index: stacking contexts explained
11 steps · about 2 h 55 min · Intermediate
- position CSS property - MDN Web Docs (reference, MDN Web Docs, 20 min)
Start with the official definitions of the five position values and of what counts as a positioned element.
- CSS The position Property (tutorial, W3Schools, 15 min)
Its try-it-yourself examples let you see each position value working before you get into theory.
- CSS Positioning Explained: Absolute, Relative, Fixed & Sticky (article, DEV Community, 10 min)
A short recap that gives you a rule of thumb for when to use each position value.
- CSS Position Property — How static, relative, absolute, fixed, and sticky Actually Work (article, devprep.co, 15 min)
Covers gotchas such as fixed inside a transformed parent, which lead into stacking-context problems.
- z-index (reference, CSS-Tricks, 10 min)
Introduces z-index, the rule that it only works on positioned elements, and the first idea of a stacking context.
- Stacking context - CSS (doc, MDN Web Docs, 15 min)
Gives the formal model of stacking contexts as self-contained units along the z-axis.
- Stacking context - CSS - MDN Web Docs (doc, MDN Web Docs, 20 min)
Works through nested stacking contexts and lists what creates one, with a worked example.
- Stacking Context Is The Key To Understanding The CSS Z-Index (blog, Ben Nadel, 10 min)
Shows why z-index 1515 can lose to z-index 17, which makes the quarantine idea concrete.
- Why Z-Index Isn't Working: CSS Stacking Contexts (article, Playful Programming, 20 min)
Applies the idea to real modal and header bugs, where a child is trapped under a footer.
- CSS z-index and Stacking Context: The Complete Guide (2026) (guide, Generalist Programmer, 25 min)
Covers the default painting order, hidden triggers such as transform and opacity, and the isolation: isolate fix.
- CSS z-index Guide: How Stacking Order Really Works (guide, CSS Toolkit, 15 min)
Ends with a debugging method: find the ancestor that creates the context and fix the layering at that level.