CSS Position
The position property specifies the type of positioning method used for an element.
The CSS position property controls how an element is placed in the document. The top, right, bottom, left properties then offset it from that position.
Try It — All Position Types
Preview
Position Values Reference
| Value | Behaviour |
|---|---|
static | Default — follows normal document flow |
relative | Offset from its own normal position |
absolute | Positioned relative to nearest positioned ancestor |
fixed | Positioned relative to viewport — stays on screen when scrolling |
sticky | Normal flow until scroll threshold, then acts like fixed |
Tip:
position: absoluteneeds a positioned ancestor (relative,absolute, orfixed) to anchor to. If none exists, it anchors to the<body>.