CSS white-space Property


Example

Specify that the text in <p> elements will never wrap:

p {
    white-space: nowrap;
}

Try it yourself »

Definition and Usage

The white-space property specifies how white-space inside an element is handled.

Default value: normal
Inherited: yes
Animatable: no. Read about animatable
Version: CSS1
JavaScript syntax: object.style.whiteSpace="nowrap" Try it


Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
white-space 1.0 8.0 3.5 3.0 9.5


CSS Syntax

white-space: normal|nowrap|pre|pre-line|pre-wrap|initial|inherit;

Property Values

Value Description Play it
normal Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default Play it »
nowrap Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a <br> tag is encountered Play it »
pre Whitespace is preserved by the browser. Text will only wrap on line breaks. Acts like the <pre> tag in HTML Play it »
pre-line Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks Play it »
pre-wrap Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks Play it »
initial Sets this property to its default value. Read about initial Play it »
inherit Inherits this property from its parent element. Read about inherit


Related Pages

CSS tutorial: CSS Text

HTML DOM reference: whiteSpace property



Color Picker

colorpicker