← All tutorials

GoCareerGo Tutorials

CSS Tutorial

Selectors, box model, Flexbox, Grid, animation and responsive design.

Explain the CSS Box Model — Interview Answer

Model answer: every element is content, wrapped by padding, then border, then margin.

Explain the CSS box model.

Every HTML element renders as a rectangular box built from four layers, from the inside out: content (the actual text/image), padding (space inside the border), border (the visible edge), and margin (space outside the border, separating it from other elements). box-sizing: content-box (default) means width/height apply only to the content; box-sizing: border-box means width/height include padding and border too, which is usually easier to reason about.