Box-sizing controls how the total width and height of an element is calculated. Mastering this property is the key to indestructible web layouts.
1The Default (content-box)
In the default content-box model, the width you set applies only to the content area. If you add 20px of padding and a 2px border, your element will actually be 44px wider than the width you declared. This is often the cause of horizontal scrollbars and broken columns in web layouts.
2The Modern Solution (border-box)
With box-sizing: border-box, the padding and border are subtracted from the content area. If you set a width of 300px, the element remains exactly 300px wide. The browser automatically reduces the internal space available for text to accommodate the padding and border. This makes responsive design and grid layouts much easier to manage.
