z-index and stacking

Which element appears on top when they overlap.

Also called: stacking context, layer order

Domain
Languages
Source
General
Language
CSS

In plain English

It only works on positioned elements (or flex/grid children), and only within the same stacking context. "z-index: 9999 doesn't work" almost always means a parent created a new stacking context (for example with transform or opacity).

Example

The menu hid behind the map until I fixed the stacking context.

Learn more

Related terms

Added 2026-11-30 · Last reviewed 2026-11-30