CSS Tutorial
Menu
CSS Advanced
Menu
CSS Responsive
Menu
CSS Grid
Menu
CSS Box-sizing
The CSS box-sizing property enables the user to include the padding and border in an element’s total width and height.
Without the CSS box-sizing Property
By default, the width and height of an element is calculated like this:
width + padding + border = actual width of an element
height + padding + border = actual height of an element
This refers to: When the width/height of an element is set, the element often is displayed bigger than it has been set (because the element’s border and padding are added to the element’s specified width/height).
The below example illustrates two <div> elements with the same specified width and height:
CSS
Without box-sizing
This div is smaller (width is 300px and height is 100px).
This div is bigger (width is also 300px and height is 100px).