Build boxes with CSS: drill the box model, margin, padding and border in 20 visual puzzles. A beginner CSS game for browser layout from the ground up.
Padding is the space between an element's content and its border. Picture bubble wrap inside a box: padding gives the content room to breathe.
Margin is the space outside an element's border. Picture the gap between boxes on a shelf: margin sets the distance between elements.
A border is the line around an element, between the padding and the margin. A border has a thickness, a style, and a color.
Now you'll set padding, margin, AND border at once. Remember the order from inside out: content → padding → border → margin.
box-sizing: border-box changes how the browser computes size. With border-box, padding and border are INCLUDED in the width/height you set.