Every element is a box: content, padding, border, and margin. Add box-sizing: border-box so padding and border are included in the width. This is the most impactful CSS rule to add to every single project.
The Box Model
div {
width: 200px;
height: 100px;
padding: 20px; /* inside space */
border: 2px solid #333;
margin: 16px; /* outside space */
}
/* Best practice — include padding in width */
* {
box-sizing: border-box;
}
Total width = content + padding + border (with border-box)