Skip to content

QuizNot attempted

box-sizing

With width: 200px; padding: 20px; border: 5px solid, how wide is the box under content-box vs border-box?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • 250px vs 200px
  • content-box (the default) treats width as the content only, so padding and border are added on top: 200 + 2×20 + 2×5 = 250
  • border-box fits padding and border inside the 200.
  • Not 200px vs 250px: that swaps the two models.
  • Not 200px vs 200px: only border-box keeps the declared width.
  • Not 240px vs 200px: that counts the padding but forgets the 10px of border.
  • This is why resets set *, *::before, *::after { box-sizing: border-box }.