box-sizing decides what width and height include.
content-box(default): width = content only. Padding and border are added.border-box: width = content + padding + border. The box stays the size you set.
Common reset
Most projects start with:
*, *::before, *::after { box-sizing: border-box; }
This makes layouts much easier — a width: 50% column stays 50% even with padding.
Example
Example — content-box vs border-box
HTML
<style>
div { width: 250px; padding: 20px; border: 5px solid #333; margin-bottom: 10px; }
.content { box-sizing: content-box; background: #ffe2d6; }
.border { box-sizing: border-box; background: #d6f5e3; }
</style>
<div class="content">content-box: 300px wide</div>
<div class="border">border-box: 250px wide</div>