CSS white-space Property
CSS white-space
property specifies the how to handle whitespace within an element.
Usages
The following table outline the usages and version history of this property.
Default value: | normal |
Applies to: | All elements |
Inherited: | Yes |
Version: | CSS1 |
JavaScript Syntax: | object.style.whiteSpace = "nowrap" |
Syntax
Here is a syntax for the CSS white-space
property
white-space: normal | nowrap | pre | pre-line | pre-wrap | initial | inherit;
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
normal | Default. Whitespace is collapsed |
nowrap | Whitespace is collapsed. But no line breaks at all. Text wrapping is not allowed at all |
pre | Whitespace is preserved. Lines are broken by newline characters. Text wrapping is not allowed at allow |
pre-line | Whitespace is collapsed. Lines are broken by newline characters and to fill line boxes. Text wrapping is allowed at all |
pre-wrap | Whitespace is preserved. Lines are broken by newline characters. Text wrapping is allowed |
initial | Sets default value of this property |
inherit | Inherits this property from its parent element |
Examples
The example below shows to sets white-space property.
p.one {
white-space: nowrap;
}
p.two {
white-space: pre;
}
p.three {
white-space: pre-line;
}
p.four {
white-space: pre-wrap;
}
Browser Compatibility
- Google Chrome 1+
- Mozilla Firefox 3.5+
- Internet Explorer 8+
- Opera 9.5+
- Safari 3+
Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.