HTML & CSS · Junior · Question 20 of 75
What is an element with position: absolute positioned relative to?
- ✓Correct answer: The nearest ancestor whose
positionis notstatic - 2Always
<body>, regardless of ancestor styles - 3Its own normal place in the flow, like
relative
Explanation
An absolute element leaves the flow and measures top/left/... from its containing block - the nearest positioned ancestor (relative, absolute, fixed, sticky). If there is none, it uses the initial containing block. That's why, to pin a close button to a card's corner, the card gets position: relative.