HTML & CSS · Junior · Question 21 of 75

How does position: sticky; top: 0 work?

Explanation

sticky is a hybrid of relative and fixed: before the threshold it's in flow, after it - pinned until its parent container ends. Common reasons sticky "doesn't work": no top is set, an ancestor has overflow: hidden/auto, or the parent is no taller than the element itself.

Further reading

Problem with a question

HTML & CSS · Junior · question 21

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