positioning

position

Controls how an element is positioned in the document and whether it participates in normal flow. Non-static values enable top/right/bottom/left offsets and create a positioning context.

position: static | relative | absolute | fixed | sticky

Common values

Value Effect
static Default; element sits in normal flow
relative Stays in flow but can be offset from its normal spot
absolute Removed from flow; positioned relative to nearest positioned ancestor
fixed Positioned relative to the viewport, ignoring scroll
sticky Behaves relatively until a scroll threshold, then sticks

Examples

.tooltip { position: absolute; top: 100%; left: 0; }

Pins tooltip just below a relatively-positioned parent

.header { position: sticky; top: 0; }

Header sticks to top of viewport on scroll

.modal { position: fixed; inset: 0; }

Fills viewport regardless of scrolling

Gotcha

sticky needs a scroll container without overflow: hidden and requires a threshold (top/left/etc.) to activate.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox