Course contentsShow
← Web Development
Lesson 234 of 2,9824. CSS Layout FoundationsFree lesson

Isolation Property

Using isolation: isolate to explicitly create a stacking context without side effects from other properties.

Isolation Property

What You'll Learn

You'll learn how to use isolation: isolate to create a clean stacking context that prevents unexpected layering issues.

The Core Idea

Sometimes you need to create a new stacking context just to control how elements layer on top of each other, without fiddling with z-index, opacity, transforms, or other properties that have side effects. That's where the isolation property comes in.

Think of it like putting a group of items in a clear container. Whatever stacking order exists inside that container stays inside—it won't interfere with items outside the container, and outside items won't interfere with what's inside.

How It Works

The isolation property has two values:

  • auto (default): No new stacking context is created
  • isolate: Explicitly creates a new stacking context

When you set isolation: isolate on an element, you're telling the browser: "Make this element its own stacking world." All its children stack relative to each other and to this parent, but they're isolated from the broader page's stacking order.

Why Use It?

You might use isolation: isolate when:

  • You want a stacking context without the visual side effects of opacity: 0.99 or transform: translateZ(0)
  • You're building a component that should layer independently
  • You need to prevent z-index values inside a component from competing with outside elements

It's a clean, explicit way to say "new stacking context here" without changing how anything looks or behaves—just how it layers.

Key Takeaway: isolation: isolate creates a stacking context explicitly and cleanly, containing all internal stacking order without any visual side effects.