
The CSS Box Model: Margin, Border, Padding, and Content
The CSS box model describes every element as four nested layers: content in the center, padding around it, a border around the padding, and margin outside.
CSS looks simple until a style refuses to apply and you have no idea why. This section covers the mechanics that decide what actually renders: the cascade, specificity, inheritance, and the box model that governs every element's size. We keep the explanations concrete. Instead of definitions you forget in an hour, each guide shows the exact code, what the browser does with it, and the one insight that makes the behavior click for good.

The CSS box model describes every element as four nested layers: content in the center, padding around it, a border around the padding, and margin outside.

CSS specificity is the scoring system browsers use to decide which rule wins when several target the same element.

CSS units are either absolute (px, which never changes) or relative (em, rem, %, vw, vh, which scale against a reference).

CSS (Cascading Style Sheets) is the language that controls how a web page looks.