HTML & CSS · Junior · Question 13 of 75

What does box-sizing: border-box do?

Explanation

With content-box (the default), width sets only the content width, and padding and border are added on top: width: 200px + padding: 20px = 240px. With border-box, the total width is exactly 200px and the content shrinks. That's why many CSS resets apply border-box to every element. margin is never part of the size.

Further reading

Problem with a question

HTML & CSS · Junior · question 13

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