CSS/Properties/white-space

From W3C Wiki
Jump to: navigation, search

white-space

The white-space property declares how white space inside the element is handled.

Description

Values normal | pre | nowrap | pre-wrap | pre-line | inherit
Initial value normal
Applies to All elements
Inherited Yes


Values

  • normal
    This value directs user agents to collapse sequences of white space, and break lines as necessary to fill line boxes.


  • pre
    This value prevents user agents from collapsing sequences of white space. Lines are only broken at newlines in the source, or at occurrences of "\A" in generated content.


  • nowrap
    This value collapses white space as for 'normal', but suppresses line breaks within text.


  • pre-wrap
    This value prevents user agents from collapsing sequences of white space. 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 white space. Lines are broken at newlines in the source, at occurrences of "\A" in generated content, and as necessary to fill line boxes.


  • inherit
    Takes the same specified value as the property for the element's parent.


Example

Example A

[style.css]

 p#no{ white-space: normal; }
 p#pre{ white-space: pre; }

[index.html]

<body>
  <p id="no">
    This is a paragraph.
    This is a paragraph.
    This is a paragraph.
  </p>

  <p id="pre">
    This is a paragraph.
    This is a paragraph.
    This is a paragraph.
  </p>
</body>

Csslist2 white-space.png

CSS Reference

The CSS specification defines the white-space property in 16.6 White space.