HTML and CSS Reference
In-Depth Information
Table 6-1. CSS Width and Height Properties
Property
Initial Value
Inherited
Description
width
auto
No
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
content.
min-width *
0
No
Sets a minimum width for an element.
max-width *
none
No
Sets a maximum width for an element.
height
auto
No
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.
min-height *
0
No
Sets a minimum height for an element.
max-height *
none
No
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.
Caution
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 .
 
 
Search WWH ::




Custom Search