static
Default. The element participates in normal flow.
Positioning moves elements out of ordinary flow relationships. It is powerful for badges, overlays and anchored UI, but it can break layout when overused.
.card { position: relative; }
.badge { position: absolute; inset: 1rem 1rem auto auto; }
Layout
The default position is static. An element stays in normal flow. position: relative keeps the element in flow but can offset it and create a containing block for absolute children.
position: absolute removes an element from normal flow and positions it relative to its nearest positioned ancestor.
position: fixed pins an element to the viewport. These tools are useful, but they should not replace layout systems like flex and grid.
Default. The element participates in normal flow.
Keeps its space but can become an anchor for absolute children.
Removed from flow and positioned within a containing block.
Pinned to the viewport, often used for overlays or floating controls.
Visual model
Good layout CSS is not a pile of positions. It is a set of relationships: flow, axis, tracks, placement, layering, sticking and rhythm.
Creates the containing block.
Anchored to the parent corner.
Still controls the card layout.
Pinned independent of document flow.
Examples
.card { position: relative; }
.badge {
position: absolute;
inset-block-start: 1rem;
inset-inline-end: 1rem;
}
.header { position: absolute; top: 22px; left: 80px; }
.main { position: absolute; top: 180px; left: 260px; }
.footer { position: absolute; top: 940px; left: 80px; }
Rules that matter
Layout work is where real content, real devices and real users expose weak assumptions. The goal is a structure that explains itself in code and survives change.
A positioned parent gives absolute children a clear reference.
Badges, icons and overlays are good positioning use cases.
Flow, flex and grid are safer for page structure.
inset-block and inset-inline adapt better to writing modes.
Positioned elements may interact with z-index.
Offsets that look good on desktop may fail on mobile.
Production thinking
Positioning lets you attach visual details precisely, but it bypasses some natural layout behavior.
Positioned content should not cover controls, hide focus states or create confusing reading order.
Use positioning for anchored UI details, modals, tooltips and fixed controls. Keep main layout in flow, flex or grid.
Positioning does not change meaning, but hidden or overlapping content can hurt user experience.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If the answer is vague, change the lab layout and inspect the result.
Senior audit upgrade
Absolutely positioned elements look for a positioned ancestor. Fixed elements can also behave differently on mobile when transforms or viewport UI are involved.
Use position: relative on the intended parent before placing an absolute child.
Test fixed headers and buttons on real mobile sizes, including browser chrome changes.
Do not use absolute positioning for ordinary document layout.