From the course: CSS Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Box-sizing and the box model fix

Box-sizing and the box model fix - CSS Tutorial

From the course: CSS Essential Training

Box-sizing and the box model fix

- [Presenter] Using different box model properties affects the overall size of the element. This behavior can be managed with the box-sizing property, which defines how the total width and height of an element are calculated. There are two values, content-box and border-box. The default box-sizing value is content-box. The width and height values apply to the content-box of the element. Any added border or padding styles will increase the element's total size. Margin adds space around the element, so it's not included in the total size of the element, but it does affect how much space the element takes up. When the border-box value is used, the width and height will still be applied to the content-box. However, when padding and border styles are added, the content-box shrinks to maintain the same overall size as defined by the width and height properties. Again, margin is not included in these adjustments, since it adds space…

Contents