π What is isolation?
The isolation property determines whether an element shouldcreate its own stacking context. By default, elements participate in the stacking context of their parent, meaning z-index values can overlap across siblings.
Note
β Helpful for complex UIs, modals, effects, and compositing
π― Why Use isolation?
- Prevent child elements from interfering with siblings via z-index
- Ensure predictable layering inside components
- Fix z-index problems in nested layouts
- Useful in UI frameworks with overlays, dropdowns, modals
- Creates a new compositing layer in some browsers for complex effects
π Syntax
isolation Syntax
isolation: auto | isolate;π Values Explained
| Value | Description |
|---|---|
| auto (default) | Element does NOT create a new stacking context unless other properties force it |
| isolate | Forces the element to create its own stacking context |
Note
π§ͺ Example 1 β Preventing z-index Conflicts
z-index Problem Fix
.parent {
position: relative;
isolation: isolate;
}
.child1 {
position: absolute;
z-index: 9999; /* High z-index won't escape the parent */
}
.child2 {
position: absolute;
z-index: 1;
}With isolation: isolate, even a child with huge z-index cannot overlap elements outside this parent.
π§ͺ Example 2 β Modal or Dropdown Inside Complex UI
Modal Inside Component
.component {
isolation: isolate; /* Create a self-contained layering system */
}
.dropdown {
position: absolute;
z-index: 1000; /* Only affects layering inside component */
}This prevents your dropdown or tooltip from accidentally appearing behind other unrelated elements.
π§ͺ Example 3 β Prevent Effects from Blending
Isolation also prevents backgrounds from blending across layers when using mix-blend-mode or backdrop-filter.
Blend Mode Issue Fix
.container {
isolation: isolate;
}
.overlay {
mix-blend-mode: multiply;
}Prevents the blend effect from affecting elements outside `.container`.
π¨ Visual Diagram

Without isolation β children stack globally With isolation β children stack only within their own context
π§ How Stacking Contexts Work
A stacking context is like a mini-layering system. Elements inside it layer relative to each other but cannot overlap elements outside unless specifically allowed.
- z-index only works inside the same stacking context
- opacity < 1, transform, filter, and position changes can create new stacking contexts
- isolation: isolate creates one intentionally
π± Example β Fixing Unexpected Overlaps
Unwanted Overlap Fix
.sidebar {
position: relative;
z-index: 10;
}
.main {
position: relative;
isolation: isolate; /* Prevents sidebar from overlapping children */
}β οΈ Common Mistakes
- β Expecting isolation to control stacking order alone β Only creates context, doesn't reorder elements
- β Using isolate everywhere β Can cause unnecessary stacking contexts and affect performance
- β Forgetting that other CSS properties also create stacking contexts
- β Thinking isolation clips content (it does NOT clip)
Note
π₯ Summary
The isolation property is a powerful solution for managing z-index conflicts and creating self-contained layering blocks. Itβs essential for building reliable dropdowns, modals, tooltips, and any UI where layered content must behave predictably.
Learn more βMDN Docs π