Skip to the page
css reference · the box model

CSS box-sizing

type
property
applies to
any element
inherits
no
common values
content-box (default), border-box

Where it goes

Almost always set once, for everything, at the top of a stylesheet: * { box-sizing: border-box; }.

Example

* {
  box-sizing: border-box;
}

.card {
  width: 300px;
  padding: 20px; /* included in that 300px, not added to it */
}

Common mistakes

  • Setting width: 100% on a box with padding under the default. The padding is added on top and the box spills out of its parent.
  • Setting border-box on one tag but not the rest. Two sizing models on the same page give sizes that do not line up.

Related

Updated 24 October 2026. Practice it in the css route, or read more on MDN.