Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. white-space

white-space

Specifies how whitespace characters (spaces, tab characters, and line breaks) in text are displayed.

Sample Code

p.test { white-space: normal;}
p.test1 { white-space: pre;}
p.test2 { white-space: nowrap;}

Available Values

ValueDescription
normalConsecutive spaces, tabs, and line breaks in the text are displayed as a single space. Text wraps automatically to fit the containing element's width. This 'normal' is the initial value.
preSpaces, tabs, and line breaks in the text are preserved and displayed as-is.
nowrapConsecutive spaces, tabs, and line breaks in the text are displayed as a single space. Text does not wrap automatically.

Browser Display Result

These samples use the following string:

This is a p element.     Text. Text.
		Text. Text. Text.
<p style="border: solid 1px; white-space: normal; width: 200px;">This is a p element.     Text. Text.
Text. Text. Text.</p>

<p style="border: solid 1px; white-space: pre; width: 200px;">This is a p element.     Text. Text.
Text. Text. Text.</p>

<p style="border: solid 1px; white-space: nowrap; width: 200px;">This is a p element.     Text. Text.
Text. Text. Text.</p>

Browser Compatibility

Chrome Chrome
1+
Firefox Firefox
1+
Safari Safari
1+
Edge Edge
12+
Supported in all versions
IE IE
11
10
9
8
7
6
Opera Opera
4+
3 and earlier ×
iOS Safari iOS Safari
1+
Android Android Browser
4.4+
3 and earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop
Firefox Android Firefox Android
Latest
Same support as desktop

※ Version data is based on MDN.

If you find any errors or copyright issues, please .