CSS isolation Property

The CSS isolation property determines whether an element creates a new stacking context, allowing its contents to be composited independently from surrounding elements.

It is particularly useful with mix-blend-mode, where overlapping elements can blend with colors and backgrounds behind them. Setting isolation: isolate establishes a boundary for blending and helps manage stacking behavior in complex layouts.

isolation Syntax

The isolation property accepts one of two keyword values: auto or isolate.

Basic Syntax

selector {
  isolation: isolate;
}

Default Value

.container {
  isolation: auto;
}

Create a Stacking Context

.container {
  isolation: isolate;
}

CSS-Wide Keywords

.container {
  isolation: initial;
}
.container {
  isolation: inherit;
}
.container {
  isolation: unset;
}
.container {
  isolation: revert;
}
.container {
  isolation: revert-layer;
}

The initial value is auto. Setting isolation: isolate explicitly creates a stacking context, even when the element is not positioned.

Property Values

The isolation property accepts the following values.

Value Description
auto Does not create a stacking context specifically because of the isolation property. This is the initial value.
isolate Creates a new stacking context and establishes an isolated group for compositing and blending.
initial Resets the property to auto.
inherit Uses the computed value from the parent element.
unset Resets the property to auto because it is not inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value auto
Inherited No
Applies to All elements
Computed value As specified
Animation type Discrete
Percentages Not applicable
Creates stacking context Yes, when set to isolate

The property controls compositing and stacking behavior rather than an element's size, position, or visibility.

How It Works

When an element uses isolation: isolate, the browser creates a new stacking context. Its descendants are stacked together as a group within the surrounding stacking context.

Without Explicit Isolation

.container {
  isolation: auto;
}

The element does not establish a stacking context solely because of isolation. Its descendants may participate in an ancestor stacking context, depending on other CSS properties.

With Explicit Isolation

.container {
  isolation: isolate;
}

The container establishes its own stacking context. Its descendants are stacked within that context before the entire group is composited into the surrounding page.

Important Consideration

The isolation property does not prevent descendants from overlapping one another. It establishes a boundary for stacking and blending with content outside the isolated group.

auto Value

The auto value is the default. It does not force the element to establish a new stacking context.

Default Isolation

.container {
  isolation: auto;
}

Blending Without an Isolated Group

.container {
  isolation: auto;
}
.container .overlay {
  mix-blend-mode: multiply;
}

Depending on the surrounding stacking and compositing structure, the overlay may blend with content outside the container.

Other Stacking Context Triggers

.container {
  isolation: auto;
  opacity: 0.8;
}

Even with isolation: auto, other properties such as an opacity below 1 can establish a stacking context.

Important Consideration

auto does not mean that the element can never be isolated. It means the isolation property itself does not require an isolated stacking context.

isolate Value

The isolate value explicitly creates a stacking context and an isolated compositing group.

Isolate a Component

.component {
  isolation: isolate;
}

Isolate a Card

.card {
  isolation: isolate;
  background-color: #fff;
}

Isolate a Blending Group

.blend-group {
  isolation: isolate;
}
.blend-group .shape {
  mix-blend-mode: multiply;
}

The blending shapes can interact with content inside the isolated group without blending directly with content behind the group.

Important Consideration

Isolation does not create a clipping boundary. Descendants may still extend beyond the element's visible box unless overflow or another clipping mechanism restricts them.

Stacking Contexts

A stacking context is a group of elements whose stacking order is managed independently from surrounding content.

When isolation: isolate is applied, the element becomes the root of a new stacking context. Its descendants cannot use their own z-index values to escape that context's position in the parent stacking order.

Create a Stacking Context

.container {
  isolation: isolate;
}

Stack Descendants

.container {
  isolation: isolate;
}
.container .background {
  position: absolute;
  z-index: 0;
}
.container .content {
  position: relative;
  z-index: 1;
}

The background and content are stacked within the container's stacking context.

Other Ways to Create Stacking Contexts

Stacking contexts can also be established by several other CSS features, including:

  • A positioned element with a non-auto z-index.
  • A fixed or sticky positioned element.
  • An element with opacity below 1.
  • An element with a non-none transform.
  • An element with a non-normal mix-blend-mode.
  • Certain containment, filtering, and other compositing properties.

Important Consideration

Creating a stacking context does not automatically place the element above all surrounding content. Its position in the parent stacking context still follows the applicable stacking rules.

isolation and mix-blend-mode

The mix-blend-mode property controls how an element's pixels blend with the backdrop. The isolation property can restrict which backdrop content participates in that blending.

Blending Without Isolation

.container {
  isolation: auto;
}
.container .shape {
  mix-blend-mode: multiply;
}

The shape may blend with content outside the container if the surrounding compositing structure permits it.

Blending with Isolation

.container {
  isolation: isolate;
}
.container .shape {
  mix-blend-mode: multiply;
}

The shape's blending is restricted to the isolated group. Content behind the group is not included in the shape's blending backdrop.

Multiple Blending Elements

.artwork {
  isolation: isolate;
}
.artwork .shape-one {
  background-color: #2563eb;
  mix-blend-mode: multiply;
}
.artwork .shape-two {
  background-color: #f97316;
  mix-blend-mode: multiply;
}

The shapes can blend with one another inside the isolated artwork without directly blending with surrounding page content.

Important Consideration

Isolation does not disable mix-blend-mode. It limits the backdrop available to blending descendants.

Background Blending

The background-blend-mode property blends multiple background layers belonging to the same element. It is different from mix-blend-mode, which blends an element with its backdrop.

Blend Background Layers

.banner {
  background-image: linear-gradient(#2563eb, #9333ea), linear-gradient(#f97316, #facc15);
  background-blend-mode: multiply;
}

The background layers blend within the banner's own background painting area.

Combine with Isolation

.banner {
  isolation: isolate;
  background-image: linear-gradient(#2563eb, #9333ea), linear-gradient(#f97316, #facc15);
  background-blend-mode: multiply;
}

The background layers still blend with one another. Isolation also establishes a stacking context for the banner and its descendants.

Important Consideration

background-blend-mode does not require isolation: isolate to blend background layers. Use isolation when a separate stacking or compositing boundary is needed.

isolation and z-index

The z-index property controls stacking order in applicable stacking contexts. Isolation changes the context within which descendant stacking levels are evaluated.

Isolated Container

.container {
  isolation: isolate;
}
.container .overlay {
  position: absolute;
  z-index: 100;
}

The overlay's z-index is evaluated within the isolated container's stacking context.

Sibling Stacking Contexts

.card-one {
  position: relative;
  z-index: 1;
  isolation: isolate;
}
.card-two {
  position: relative;
  z-index: 2;
}
.card-one .overlay {
  position: absolute;
  z-index: 999;
}

The overlay cannot rise above .card-two solely because its own z-index is larger. Its entire stacking context remains below the second card's higher stacking level.

Important Consideration

A large z-index value cannot escape an ancestor stacking context. When debugging stacking problems, inspect the stacking contexts of the element's ancestors.

Positioning and Isolation

The isolation property creates a stacking context without requiring position: relative, absolute, or another positioning value.

Isolation Without Positioning

.component {
  isolation: isolate;
}

This creates a stacking context while leaving the element's normal positioning behavior unchanged.

Isolation with Relative Positioning

.component {
  position: relative;
  isolation: isolate;
}

Relative positioning can establish a containing block for absolutely positioned descendants, while isolation establishes a stacking context.

Absolute Positioning

.component {
  position: relative;
  isolation: isolate;
}
.component .badge {
  position: absolute;
  inset-block-start: 10px;
  inset-inline-end: 10px;
}

Important Consideration

Isolation alone does not establish a containing block for absolutely positioned descendants. Use an appropriate positioning or containing-block property when needed.

Flexbox and Grid

The isolation property can be applied to flex and grid containers or their items without changing the underlying flex or grid layout algorithms.

Isolate a Flex Item

.flex-container {
  display: flex;
  gap: 20px;
}
.flex-item {
  isolation: isolate;
}

Isolate a Grid Item

.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.grid-item {
  isolation: isolate;
}

Isolate an Entire Grid

.grid-container {
  display: grid;
  isolation: isolate;
}

This creates a stacking context around the entire grid container rather than separately isolating each item.

Important Consideration

Isolation does not change track sizing, alignment, item order, or spacing. It affects stacking and compositing behavior.

Pseudo-Elements

Isolation can be useful when pseudo-elements create decorative backgrounds or overlays behind an element's content.

Decorative Background

.card {
  position: relative;
  isolation: isolate;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, #bfdbfe, #ddd6fe);
}

The isolated stacking context helps keep the negatively stacked pseudo-element behind the card's content without allowing it to escape into an ancestor stacking context.

Blending Pseudo-Element

.card {
  position: relative;
  isolation: isolate;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: #2563eb;
  mix-blend-mode: multiply;
  pointer-events: none;
}

The pseudo-element blends within the isolated card group rather than directly with surrounding page content.

Important Consideration

Isolation does not guarantee that a pseudo-element appears behind all other content. Its position depends on the stacking order and applicable z-index values.

Inheritance

The isolation property is not inherited. Its initial value is auto.

Parent Isolation

.parent {
  isolation: isolate;
}

Descendants participate in the parent's stacking context, but they do not automatically receive isolation: isolate as their own computed value.

Explicit Inheritance

.child {
  isolation: inherit;
}

This makes the child use its parent's computed isolation value.

Reset to Initial Value

.child {
  isolation: initial;
}

This resets the property to auto.

Using unset

.child {
  isolation: unset;
}

Because the property is not inherited, unset behaves like initial.

Important Consideration

A child does not need its own isolation: isolate declaration to be part of an ancestor's isolated stacking context.

isolation Example

This example compares two groups containing overlapping, blended circles. Both groups sit on a colored background, but only the second group uses isolation: isolate.

HTML Example

<div class="isolation-demo">
  <div class="demo-panel">
    <h3>Without Isolation</h3>
    <div class="demo-stage no-isolation">
      <div class="circle circle-one"></div>
      <div class="circle circle-two"></div>
    </div>
  </div>
  <div class="demo-panel">
    <h3>With Isolation</h3>
    <div class="demo-stage isolated">
      <div class="circle circle-one"></div>
      <div class="circle circle-two"></div>
    </div>
  </div>
</div>

CSS Example

.isolation-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.isolation-demo .demo-panel {
  flex: 1 1 220px;
  min-width: 0;
  padding: 15px;
  background-color: #facc15;
}
.isolation-demo h3 {
  margin: 0 0 15px;
  font-size: 1rem;
  color: #1f2937;
}
.isolation-demo .demo-stage {
  position: relative;
  height: 150px;
}
.isolation-demo .no-isolation {
  isolation: auto;
}
.isolation-demo .isolated {
  isolation: isolate;
}
.isolation-demo .circle {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  mix-blend-mode: multiply;
}
.isolation-demo .circle-one {
  top: 10px;
  left: 15px;
  background-color: #2563eb;
}
.isolation-demo .circle-two {
  top: 40px;
  left: 75px;
  background-color: #f43f5e;
}
Browser Result

Without Isolation

With Isolation

Without isolation, the circles can blend with the yellow panel background. With isolation, the circles blend within their own group, preventing the yellow background outside that group from participating in their blending.

Try Removing Isolation

.isolation-demo .isolated {
  isolation: auto;
}

Both groups now use the same isolation setting, allowing the blending behavior to match when no other stacking context separates them.

Try a Different Blend Mode

.isolation-demo .circle {
  mix-blend-mode: screen;
}

The screen blend mode produces a lighter combination of overlapping colors. Isolation still controls whether the external background participates in the blend.

Common Mistakes

Using an Invalid Value

.container {
  isolation: hidden;
}

This is invalid. The property accepts auto or isolate, along with CSS-wide keywords.

Expecting Isolation to Hide Overflow

.container {
  isolation: isolate;
}

Isolation does not clip content. Use an appropriate overflow or clipping property when descendants must be restricted to a boundary.

Expecting Isolation to Disable Blending

Isolation does not turn off mix-blend-mode. It changes the blending boundary.

Expecting Isolation to Change Layout

The property does not change flexbox, grid, normal flow, dimensions, or element alignment.

Using z-index Without Considering Ancestors

.parent {
  isolation: isolate;
}
.child {
  position: absolute;
  z-index: 9999;
}

The child's large z-index does not allow it to escape the parent's stacking context.

Assuming Isolation Establishes a Positioning Container

Isolation creates a stacking context, not necessarily a containing block for absolute positioning. These are separate CSS concepts.

Applying Isolation Unnecessarily

Creating additional stacking contexts can complicate stacking relationships. Apply isolation where independent stacking or blending behavior is needed.

Important Considerations

Keep the following points in mind when using isolation:

  • The property controls whether an element explicitly creates an isolated stacking context.
  • It accepts auto and isolate.
  • The initial value is auto.
  • The property is not inherited.
  • isolation: isolate creates a stacking context.
  • isolation: auto does not prevent other properties from creating stacking contexts.
  • Isolation can restrict the backdrop used by descendants with mix-blend-mode.
  • Blending can still occur between descendants inside an isolated group.
  • Isolation does not disable blending effects.
  • Isolation does not change element dimensions or normal layout flow.
  • Isolation does not automatically clip overflowing descendants.
  • Isolation does not require an element to be positioned.
  • Isolation alone does not establish a containing block for absolute positioning.
  • Descendant z-index values remain within their ancestor stacking contexts.
  • Isolation can be applied to flex and grid containers or items.
  • Isolation can help organize decorative pseudo-elements and overlays.
  • The property animates discretely rather than interpolating between values.
  • Use isolation when a separate stacking or compositing boundary is necessary.

Browser Support

The CSS isolation property is widely supported in modern browsers, including Chrome, Edge, Firefox, Safari, and Opera. It is considered a widely available CSS feature.

Both auto and isolate are supported in current major browsers. Blending results can also depend on related properties and the surrounding compositing structure.

For current compatibility information, visit Can I Use? and search for isolation.

Specifications

The isolation property is defined in the Compositing and Blending Level 1 specification.

Compositing and Blending Level 1: Isolation

The specification describes isolated groups, blending behavior, and how compositing interacts with stacking contexts.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: isolation