CSS white-space Property
The white-space property in CSS is used to control text wrapping and white-spacing, i.e., it can be used to specify how white-space is handled within elements. This property accepts several different types of values.
The white-space property is divided into two parts: whether or not white space is collapsed and whether or not lines can wrap at soft-wrap opportunities.
Syntax
Property Values
Value | Description |
---|---|
normal | Whitespace sequences will be merged into a single whitespace. When necessary, the text will be wrapped. This is the default setting. |
nowrap | Whitespace sequences will be merged into a single whitespace. The text will never be wrapped to the next line. The text continues on the same line until it encounters a <br> tag. |
pre | The browser preserves whitespace. Only line breaks will cause text to wrap. In HTML, this is equivalent to the <pre> tag. |
pre-line | Whitespace sequences will be merged into a single whitespace. When necessary, and on line breaks, text will wrap. |
pre-wrap | The browser preserves whitespace. When necessary, and on line breaks, text will wrap. |
initial | This property is set to its default value. |
inherit | This property is inherited from its parent element. |
Supported Browsers
Property | Chrome | Firefox | Safari | Edge / IE | Opera |
---|---|---|---|---|---|
white-space | 1.0 | 3.5 | 3.0 | 8.0 | 9.5 |