CSS position Property Explained
What the CSS position property does, with an example.
Published November 3, 2026
The position property controls how an element is placed: static (default), relative, absolute, fixed or sticky. Offsets top, right, bottom and left then move it.
How it works
relative keeps the element in flow but allows offsets; absolute removes it from flow and positions relative to the nearest positioned ancestor; fixed positions relative to the viewport; sticky switches between relative and fixed on scroll.
A positioned ancestor (relative) is the usual anchor for absolute children.
Values and effects
position: static; → normal flow (default)
position: relative; → offset from its normal place
position: absolute; → relative to positioned ancestor
position: fixed; → relative to viewport
position: sticky; → sticks while scrolling
Practical examples
Badge on a card
.card { position: relative; }
.badge { position: absolute; top: .5rem; right: .5rem; }Sticky header
header { position: sticky; top: 0; z-index: 10; }Full-screen overlay
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); }Common mistakes
- Forgetting position: relative on the parent of an absolute child.
- Sticky not working because an ancestor has overflow set.
- Using fixed without accounting for mobile browser bars.
Key takeaways
- position in one line: The position property controls how an element is placed: static (default), relative, absolute, fixed or sticky.
- Inspect it live in DevTools → Styles.
- Test across browsers and screen sizes.
FAQ
Why isn't sticky working?
An ancestor with overflow: hidden/auto or no scrollable room breaks it.
Is position supported in all browsers?
Yes in all modern browsers; check caniuse.com for edge cases.