The Box Model
- Content box
- Padding box
- Border box
- Margin box
Example:
- 400 width
- 30 padding-left
- 30 padding-right
- 20 border-left
- 20 border-right
- 500px total width
Element height and width calculation
Final element width = left border + left padding + width + right padding + right border
Final element height = top border + top padding + height + bottom padding + bottom border
Box Properties
- Width
- Height
- Padding
- Margin
- Boarder
Width and Height
The width and height properties change the size of the content box. Inline elements require the display property.
Padding
Padding adds/removes space inside of the element but around the content box.
Margin
Margin adds/removes space around the element.
The border property displays a border between the margin and padding.