There are actually two box models in CSS, the standard and the alternate. By default, browsers use the standard model.
Note that the box model applies wholly to block boxes. Inline boxes only use some of the model.
inline-size
and block-size
or width
and height
.padding
and related properties.border
and related properties.margin
and related properties.In the standard box model, padding and border is added to the defined width/height dimensions to get the total size taken up by the box. e.g. 100px width + 30px padding = 160px wide box.
In the alternate box model (box-sizing: border-box
), the total size is the defined width/height. e.g. 100px width + 30px padding = 100px wide box.