Caffeinated Coder
Book an appointment
Lesson 04 · Styling basics

The box model

The browser lays out every element as a box with four layers: content, padding, border and margin. Apply one rule to a .card box, one line at a time, and watch each layer grow: width and height size the content, padding and border make the box bigger, and margin pushes the next box away. Add up the real size, then see how box-sizing: border-box makes width and height measure the whole box instead.

9 min7 steps5 questionsBeginner
Fig 4 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.