-moz-box-sizing (CSS property)
Example
This rule will cause the browser to
render the .example element using the
padding-box box sizing model:
.example {
-moz-box-sizing: padding-box;
}
Description
This property can be used to
specify the CSS box model that’s used to calculate the widths and heights
of elements. -moz-box-sizing is similar to the CSS3 proposal
called box-sizing but, again, exhibits differences: the
CSS3 proposal doesn’t include the value
padding-box.
In the following example, we
specify that the border-box box model is to be used
to calculate the dimensions of matching elements, where the padding and
borders will be included within the dimensions, rather than added to
them:
.example {
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 200px;
height: 120px;
padding: 30px;
border: 5px solid #000;
background: #ffffcc;
text-align: center;
}
The results of the CSS above can be seen in Figure 1.
border-box dimensions
As you can see, the padding and borders have not added to the element’s overall width or height. Instead, the content area has been reduced by the size of the padding. The result is the same behavior that Internet Explorer versions 6 and 7 exhibit while in quirks mode, and that Internet Explorer for Windows versions 5 and 5.5 will display at all times. There are merits in both box models, as we’ve already discussed in The Internet Explorer 5 Box Model.
Opera, since version 8.5, has supported the CSS3
box-sizing property. Safari 3 supports the
-webkit-box-sizing property, which matches the
specifications for the CSS3 property.
Value
content-box- If this value is specified, the
widthandheightproperties represent only the dimensions of the content—they don’t include the border, margin, or padding. This reflects the default CSS2 box model. padding-box- If the value
padding-boxis specified, thewidthandheightproperties include the padding size with the content dimensions, but don’t include the border or margin. This value isn’t included in the CSS3box-sizingproperty specifications. border-box- If the value
border-boxis specified, the width and height properties represent the sum of the padding size, border size, and the content dimensions, but don’t include the margin. This box sizing model reflects the IE5 box model.
Compatibility
| IE | 5.5 | None |
|---|---|---|
| 6.0 | None | |
| 7.0 | None | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | None |
| 2.0 | None | |
| 3.0 | None | |
| Opera | 9.2 | None |
| 9.5 | None |
This is a proprietary Mozilla extension to the CSS standard.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

