HTML and CSS Reference
Table 6-1. CSS Width and Height Properties
Sets the width for an element. Can be
applied to any element, except inline text,
or table rows. If no value is specified, the
element expands horizontally as far as
possible to accommodate the element's
Sets a minimum width for an element.
Sets a maximum width for an element.
Sets the height for an element. Can be
applied to any element, except inline text, or
table columns. If no value is specified, the
element expands vertically as far as possible
to accommodate the element's content.
Sets a minimum height for an element.
Sets a maximum height for an element.
* Internet Explorer 6 does not support the min- and max- properties.
All six properties accept values expressed as a length (for example, pixels or ems) or as a percentage. When a
percentage is used, the width or height is calculated as a percentage of the parent element's width or height.
The default for min-width and min-height is 0 , whereas the default for max-width and max-height is
none . Although these sound just two ways of saying the same thing, 0 means “there is no minimum,” and none
means “there is no maximum.” So, unless you specify a minimum, the element will collapse to nothing if it has
no content. If you specify no maximum, the element will expand horizontally or vertically as far as it can to
accommodate its content.
■ in the standard box model, width and height refer to the dimensions of the content , not the element's
overall size. Padding and borders are added to the width and height, not included.
Using Padding and Margins to Add Space Around Elements
Both padding and margins add vertical and horizontal space around elements. Sometimes, it doesn't matter
which you use, because they appear to have the same effect. However, there are important differences, as
described in Table 6-2 .