HTML & CSS · Junior · Question 20 of 75

What is an element with position: absolute positioned relative to?

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.

Further reading

Problem with a question

HTML & CSS · Junior · question 20

Test yourself

Take the HTML & CSS · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz