White-space

From Htmlpedia
Jump to: navigation, search

CSS 1 property: white-space

This property declares how whitespace inside the element is handled. Values have the following meanings:

normal 
This value directs user agents to collapse sequences of whitespace, and break lines as necessary to fill line boxes.
pre 
This value prevents user agents from collapsing sequences of whitespace. Lines are only broken at newlines in the source, or at occurrences of "\A" in generated content.
nowrap 
This value collapses whitespace as for 'normal', but suppresses line breaks within text.
pre-wrap 
This value prevents user agents from collapsing sequences of whitespace. Lines are broken at newlines in the source, at occurrences of "\A" in generated content, and as necessary to fill line boxes.
pre-line 
This value directs user agents to collapse sequences of whitespace. Lines are broken at newlines in the source, at occurrences of "\A" in generated content, and as necessary to fill line boxes.

Property Values

This property accepts the following values:

  • normal (default)
  • pre
  • nowrap
  • pre-wrap
  • pre-line

Example

Good
<style type="text/css">
     .like_pre { white-space: pre; }
</style>
...
<p class="like_pre">Contents</p>

Browser Support

If you have tested support for this property in any of the following browsers, please indicate its level of support using one of the following keywords:

  • Full
  • Partial
  • Buggy
  • None

If you indicate that support is "Partial" or "Buggy," please add further comments explaining what's missing or what doesn't work right.

Browser white-space support
IE 3 unknown
IE 4 unknown
IE 5 unknown
IE 5.5 unknown
IE 6 unknown
IE 7 Full
NS 3 unknown
NS 4 unknown
NS 4.5 unknown
NS 6 unknown
NS 7 unknown
NS 8 unknown
Firefox 1 unknown
Firefox 1.5 unknown
Firefox 2 Full
Mozilla unknown
Opera 6 unknown
Opera 7 unknown
Opera 8 unknown
Opera 9 Full
Safari 3 Full *1

*1: tested with: Safari for Windows 3.0.3

Tips and Tricks

If you know of any useful or uncommon tips or techniques using this property, please describe them here.

References