The box model is how browsers calculate the physical space every HTML element occupies on a page. Every element is treated as a rectangular box made up of 4 layers, from the inside out: the content area, padding, border, and margin.
Content is the actual text or image. Padding is the transparent space between the content and the border. Border is the line around the element (which may be invisible, but it still exists and takes up space). Margin is the transparent space outside the border, which separates the element from its neighbors.
The box model is why elements don't sit exactly where you expect them to, and why changing padding in one place can shift everything around it. There's also a behavior called margin collapsing: when 2 elements with vertical margins are adjacent, the browser doesn't add the margins together. It uses only the larger of the 2 values. So setting a 40px bottom margin on one element and a 40px top margin on the next element doesn't give you 80px of space. It gives you 40px. This counterintuitive behavior produces spacing results that look like bugs but are actually specified CSS behavior.
