Name
white-space — NN 4 IE n/a CSS 1
Synopsis
Inherited: Yes
Sets how the browser should render whitespace (extra character spaces
and carriage returns) that is part of the element’s source
code. Under normal circumstances, HTML ignores extra whitespace and
thus collapses the rendered content around such space. For example,
only single spaces are preserved between words and
BR elements are required to force a line break
within a paragraph. A whitespace attribute setting of
pre treats whitespace as if you had surrounded the
element in a PRE element. But although browsers
have a tradition of rendering PRE elements in a
monospace font, the look of an ordinary element set to
white-space:pre preserves its font
characteristics.
CSS Syntax
white-space: whiteSpaceTypeJavaScript Equivalent
whiteSpace
Value
One of three constants: normal |
nowrap | pre. A value of
normal allows regular HTML treatment of whitespace
to rule. A value of nowrap (not available in
Navigator 4) tells the browser to ignore line breaks in the source
text (in case the author breaks up lines for readability in the
editor) and break them on the page only where there are explicit HTML
line breaks (with a BR element, for example). A
value of pre has the browser honor all whitespace
entered by the author in the source content, without adjusting any
font settings of the element.
Initial Value
normal
Example
DIV.example {white-space: pre}Applies To
Block-level elements.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access