CSS box-sizing Property
Description
The box-sizing property controls how an element’s rectangular box is measured and how that measurement relates to the spaces added around its content. In other words, it changes whether the element’s set width and height refer only to the content area or to the content plus other parts of the box. This subtle distinction has a big effect on layout calculations and the way elements fit together in a flow.
When you change how an element’s box is calculated, it directly affects how values like padding and border influence the element’s overall footprint. With one calculation model, adding padding or border increases the element’s outer size; with the alternative model, the outer size stays fixed and those decorations are accommodated within the specified dimensions. Note that spacing created by margin remains outside of those inner calculations and still pushes other elements away.
This property is particularly useful when building responsive or component-based layouts: it makes sizing predictable, reduces the need for manual arithmetic when adding padding and borders, and simplifies creating consistent cards, buttons, or grid cells. It also interacts with different layout contexts (for example, elements with different display behaviors), so being explicit about the box measurement model helps avoid unexpected overflows and alignment issues across block, inline, flex, and grid containers.
In practice, deciding which measurement model to use is often about clarity and intent - whether you want components to occupy a constant outer size regardless of decorative additions, or whether padding and borders should increase the space an element consumes. When debugging layout problems, check which model an element uses so you can reason correctly about computed sizes in the inspector and make consistent choices across your stylesheet.
Definition
- Initial value
- content-box
- Applies to
- All elements that accept width or height
- Inherited
- No
- Computed value
- Specified value
- Animatable
- No
- JavaScript syntax
- object.style.boxSizing
Interactive Demo
Parent container
Child container
Syntax
box-sizing: content-box | padding-box | border-box | inherit
Values
- content-boxThis is the default style as specified by the CSS standard. The width and height properties are measured including only the content, but not the border, margin, or padding.
- padding-boxThe width and height properties include the padding size, and do not include the border or margin.
- border-boxThe width and height properties include the padding and border, but not the margin. This is the box model used by Internet Explorer when the document is in Quirks mode
Example
Browser Support
The following information will show you the current browser support for the CSS box-sizing property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
