The CSS Box Model
Every HTML element is a rectangular box. The box model describes the layers that make up that box:
- Content — The actual text or image
- Padding — Space between content and border (inside)
- Border — A line around the padding
- Margin — Space outside the border (between elements)
box-sizing
By default (content-box), padding and border are added to the width. With box-sizing: border-box, the width includes padding and border — almost always the better choice.