Introduction
In CSS, Every HTML element is a box, understanding this helps with spacing, layout, alignment and not losing your mind.
┌────────────────────────────┐ ← margin (space outside the element)
│ ┌────────────────────┐ │ ← border (the outline)
│ │ ┌────────────┐ │ │ ← padding (space inside the element)
│ │ │ CONTENT │ │ │ ← content (text, images, etc.)
│ │ └────────────┘ │ │
│ └────────────────────┘ │
└────────────────────────────┘
CSS Properties Involved:
margin: outside spacingborder: visual outlinepadding: inside spacingwidth/height: content size - does not include padding or border unless statedbox-sizing: controls how width/height are calculated