Visit Mozilla.org

CSS:white-space

From MDC

« CSS Reference

[edit] Summary

The white-space CSS property is used to to describe how whitespace inside the element is handled.

[edit] Syntax

white-space: normal | pre | nowrap | pre-wrap | -moz-pre-wrap | pre-line | inherit ;

[edit] Values

normal
all sequences of whitespace and line breaks will be collapsed. Line breaks are add to wrap the content.
pre
all white spaces in the source will be preserved, lines are only broken at newline characters in the source.
nowrap
all sequences of whitespace and line breaks will be collapsed, also line breaks (text wrapping) are suppressed within content.
pre-wrap New in Firefox 3
all white spaces in the source will be preserved, lines are broken at newline characters and as needed to wrap the content.
-moz-pre-wrap Deprecated
Same as pre-wrap, this is the Mozilla extension which became the CSS 2.1 pre-wrap, which should be used instead.
pre-line
all sequences of whitespace will be collapsed, lines are broken at newline characters and also as needed to wrap the content.
inherit
inherits from parent.

[edit] Examples

View Live Examples

code {
  white-space: pre;
}

[edit] Notes

Values pre-wrap and pre-line are not yet implemented in Mozilla. Currently you can use -moz-pre-wrap instead of pre-wrap.

[edit] Specifications

[edit] Browser compatibility

(Sample Compatibility Chart)

Browser Lowest Version
Internet Explorer 0
Firefox 0
Netscape 0
Opera 0
Safari ?


[edit] See also

text-indent, text-align, text-decoration, letter-spacing, word-spacing, text-transform, white-space, white-space-collapse, text-rendering, text-wrap, text-shadow