Every element on a web page is a rectangular box, and almost every layout problem comes back to how big that box is and how much space surrounds it. The box model describes the four layers of every box — content, padding, border, and margin — and once you can picture them, spacing and sizing stop feeling like guesswork.
This module starts with the box model itself, then looks at box-sizing, the one-line setting that changes how width and height are calculated and that most modern stylesheets switch to border-box. It then covers margin collapsing, the surprising behavior where adjacent vertical margins merge, and finishes with the display property: how block, inline, and inline-block elements flow, and which of the box properties apply to each.
Watch the lessons in order, then continue on to Typography & Colors.
A beginner-friendly look at the content, padding, border, and margin layers that make up every element — the building block of every website.
A detailed, visual explanation of the box-sizing property and the difference between the content-box and border-box values.
Why margins between adjacent block-level elements can merge into the larger of the two, and how to recognize and control that behavior.
How the display property works for block, inline, and inline-block elements, and how padding, border, and margin behave in each type.