Prev | Current Page 284 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"


width
width: { length | percentage | auto | inherit } ;
This property sets the content width of
a block or a replaced element (p. 175).
This width does not include padding,
borders, or margins??”see The CSS Box
Model (p. 142).
If the contents of a block require more
horizontal space than the width you
assign, their behavior is defined by the
overflow (p. 280) property.
Example
This style rule assigns a fixed width of 100
pixels to paragraphs within the element
with ID "example":
#example p {
width: 100px;
}
Value
The property takes a CSS length (px, pt, em, and so on), a percentage, or the keyword
auto. Negative length values are illegal.
Percentage values refer to the width of the element??™s containing block (p. 147). If the
containing block??™s width depends on this element??™s width, the resulting layout is
undefined in CSS2.1.
The special auto value allows the browser to calculate the content width
automatically on the basis of other factors.
For absolutely positioned elements, for example, the content width may be calculated
on the basis of the left (p.


Pages:
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296