position: static / relative / absolute / fixed / sticky

The market’s glass notice board with a paper Mr. Karim winds on: pick the position of Grandma Marni’s PROMO tag and scroll the paper, and the browser shows…

Why it matters

Elements floating in odd places, a badge that runs to the page corner, a sticky header that will not stick: nearly all of it is about the reference the browser uses. Knowing each value’s reference (the flow, a positioned ancestor, the viewport, the scroller) ends the guessing at top/left numbers.

The key idea

absolute is measured from the nearest ancestor whose position is not static

Common mistakes

Try it in this playground