position controls how an element is placed and whether the offset properties (top/right/bottom/left) apply.
{ : static; }
{ : relative; }
{ : absolute; }
{ : fixed; }
{ : sticky; }
absolute positions an element relative to its nearest ancestor that is positioned (anything other than static). So you set position: relative on a parent to make it the reference point:
.card {
position: relative; /* becomes the positioning context */
}
.badge {
position: absolute; /* positioned relative to .card */
top: 8px;
right: 8px; /* pins the badge to the card's top-right corner */
}
This relative-parent / absolute-child pattern is everywhere: badges, dropdowns, tooltips, close buttons.
.navbar { position: fixed; top: 0; } /* stays put on screen while scrolling */
.section-header { position: sticky; top: 0; } /* scrolls with content, then sticks at top */
top: 0), then stays there while its container is in view — great for section headers.absolute/fixed elements are removed from normal flow, so they don't reserve space — siblings act as if they aren't there, which can cause overlap. Plan for that (e.g. add padding to compensate for a fixed navbar).
position is essential for overlays, sticky headers, modals, dropdowns, and badges.
The relative-parent/absolute-child relationship and the fixed-vs-sticky distinction are the practical core you use constantly.