Describe the rectangular boxes that are generated for elements in the document tree.
Responsible for calculating:
The box has the following rules:
width
, height
, padding
, border
and margin
.height
is specified, a block element will be as high as the content it contains, plus padding
.width
is specified, a non-floated block element will expand to fit the width of its parent minus padding
.height
of an element is calculated by the content’s height
.width
of an element is calculated by the content’s width
.padding
and border
are not part of the width
and height
of an element.By default, elements have box-sizing: content-box
applied, and only the content size is being accounted for.
box-sizing: border-box
changes how the width
and height
of elements are being calculated, border
and padding
are also being included in the calculation.
height
of an element is now calculated by the content’s height
+ vertical padding
+ vertical border
width.width
of an element is now calculated by the content’s width
+ horizontal padding
+ horizontal border
width.