HTML and CSS Reference
In-Depth Information
Name
white-space
Values:
normal
|
nowrap
|
pre
|
pre-wrap
|
pre-line
Initial value:
normal
Applies to:
All elements (CSS2.1); block-level elements (CSS2)
Inherited:
No
Computed value:
Same as declared value
Description:
Defines how whitespace within an element is handled during layout.
normal
acts as web
browsers have traditionally treated text, in that it reduces any sequence of whitespace to a
single space.
pre
causes whitespace to be treated as in the HTML element
pre
, with both
whitespace and line breaks fully preserved.
nowrap
prevents an element from line-breaking, as
in the “nowrap” attribute for
td
and
th
elements in HTML4. The values
pre-wrap
and
pre-
line
were added in CSS2.1; the former causes the user agent to preserve whitespace while
still automatically wrapping lines of text, and the latter honors newline characters within the
text while collapsing all other whitespace as per
normal
.
Examples:
td {white-space: nowrap;}
tt {white-space: pre;}