# Stacking context

*noun*

say it: **“STAK-ing KON-tekst”** **/ˈstækɪŋ ˈkɑntɛkst/**

A group of layers that stack together as one. z-index only compares elements inside the same group, so a child can never rise above something outside its group.

## What is a **stacking context**?

A **stacking context** is a group whose layers stack together. `z-index` only compares elements inside the same group, which is why a huge `z-index` sometimes doesn't help.

```css
.card { position: relative; z-index: 1; }   /* a new stacking context */
.card .menu { z-index: 9999; }   /* can't rise above elements outside .card */
```

## In a sentence

- “The menu's z-index of 9999 did nothing, because its card had started a new **stacking context**.”

Level: Master · [More CSS terms at this level](https://www.ask-codey.com/glossary?category=css&level=5)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/stacking-context
