Layout & CSS More detail A2 · Formal specification Platform: Web

Stacking Context

A stacking context is a local group of CSS layers. Items are ordered inside the group first, then the whole group is placed among other groups.

See how it works
You might call it Stacking Context

See how it works

Original worked exampleStacking Context

Another example

A modal is inside a transformed card, next to a separate page header. Even z-index: 9999 cannot move the modal outside the card's stacking context. Z-index values compare only inside the context where they belong.

Main parts

  1. 01context root
  2. 02local paint order
  3. 03atomic sibling order

Use it when

Use this term to explain why one overlapping child cannot rise above an item in another layer group.

Do not use it when

Do not treat the whole page as one z-index scale or add huge values before finding the context roots.

Name used in code

context root → local paint order → atomic sibling

Before you ship

Check content order, shared design values, component consistency, contrast, zoom, and layout changes by screen size. Verify every theme, language, and state. If there is motion, offer an equal reduced-motion experience.

Request you can copy

Outcome: Use or define Stacking Context to make the visual experience clear and easy to use. User context: A modal is inside a transformed card, next to a separate page header. Even z-index: 9999 cannot move the modal outside the card's stacking context. Z-index values compare only inside the context where they belong. Design concept to apply: Stacking Context. Why it fits: Use this term to explain why one overlapping child cannot rise above an item in another layer group. Do not use it when: Do not treat the whole page as one z-index scale or add huge values before finding the context roots. Design requirements: Set the content order, shared design values, and reusable components. Define how the layout changes by screen size and state. Keep useful design choices separate from decoration. Inclusion and resilience: Check contrast, zoom, languages, themes, and reduced motion when needed. Do not use color or effects as the only way to show meaning. Acceptance criteria: The design stays clear on phones and desktops, at zoom, in every theme, and in all supported languages. Interactive states stay clear and consistent. Evidence and limits (evidence boundary): A formal document may still be a draft, release candidate, or final version. Check its status and browser or platform support. Unknowns to confirm: Brand limits, amount of content, supported themes and languages, target devices, and design-system rules.

Check this request

Review the current use of Stacking Context. Definition: A stacking context is a local group of CSS layers. Items are ordered inside the group first, then the whole group is placed among other groups. Release checks: Check content order, shared design values, component consistency, contrast, zoom, and layout changes by screen size. Verify every theme, language, and state. If there is motion, offer an equal reduced-motion experience. Before changing code, report the evidence you found, gaps, severity, and the smallest safe fix.

A2
How official is this term?

Formal specification

A published, versioned formal specification defines this term for the listed technical scope.

A formal document may still be a draft, release candidate, or final version. Check its status and browser or platform support.

Scope
CSS stacking contexts
Document status
draft
Checked on
2026-07-30

Evidence sources & scope

Authority source + Term reference · W3C CSS Working Group · draft CSS Positioned Layout Module Level 3 — Painting order and stacking contexts Painting order and stacking contexts Scope: CSS positioning; direct scope: Painting order and stacking contexts Role here: Direct term reference Source covers: canonical name, definition, semantics, implementation Authority source · W3C CSS Working Group · draft CSS Positioned Layout Module Level 3 Scope: CSS positioning Role here: Authority within stated scope Source covers: canonical name, definition, semantics, implementation

Copy it yourself

The browser could not copy this. Select the request below and copy it yourself.