Style whiteSpace property
The Style object
Definition and Usage
The whiteSpace property sets or returns how to handle tabs, line breaks and spaces in text.
Syntax
Set the whiteSpace property:
Object.style.whiteSpace="normal|nowrap|pre|inherit"
Return the whiteSpace property:
Object.style.whiteSpace
| Value | Description |
|---|---|
| normal | Default. Whitespace and line breaks are ignored automatically. |
| nowrap | Whitespace is ignored, but line breaks are not allowed. |
| pre | Line breaks and other whitespace are preserved. |
| inherit | The value of the whiteSpace property is inherited from the parent element. |
Browser support





All major browsers support the whiteSpace property.
**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".
Example
Example
Preserve line breaks and whitespace in text:
This is some text, this is some text. This is
some text, this is some text, this is some text.
Try it »
The Style object