white-space
The white-space property specifies how white space inside the element is handled.
Syntax
white-space: normal | pre | nowrap | pre-wrap | pre-line | inherit
Initial: | normal |
Applies To: | all elements |
Inherited: | yes |
Percentages: | NA |
Media: | visual |
Values
white-space: value
Value | Description |
---|---|
normal | Collapses sequences of white space and breaks lines as necessary to fill line boxes |
nowrap | Collapses sequences of white space, but suppresses line breaks within text |
pre | Prevents collapsing sequences of white space and breaks lines at newlines in the source, or at occurrences of "\A" in generated content |
pre-line | Collapses sequences of white space and breaks lines at newlines in the source, at occurrences of "\A" in generated content, and as necessary to fill line boxes |
pre-wrap | Prevents collapsing sequences of white space and breaks lines at newlines in the source, at occurrences of "\A" in generated content, and as necessary to fill line boxes |
DOM
[window.]document.getElementById("element-id").style.whiteSpace = "white-space";
Example | normal
Example | nowrap
Example | pre
Example | pre-line
Example | pre-wrap
Example | DOM
External
W3C Cascading Style Sheets, level 1
W3C Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification