English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
white-The space CSS property specifies how whitespace (such as spaces, tabs, and newline characters) is handled within an element.
The following table provides usage instructions and version history for this property, as well as the syntax for using this property in JavaScript scripts.
Default value: | normal |
---|---|
Applies to: | All elements |
Inheritance: | Yes |
Animatable: | No.Please see Animation properties. |
Version: | CSS 1,2,3 |
JavaScript syntax: | object.style.whiteSpace="pre-wrap" |
The syntax of this property is as follows:
white-space: normal | pre | nowrap | pre-line | pre-wrap | initial | inherit
The following examples demonstrate how to use white-space property.
code { white-space: pre; } p { white-space: nowrap; }Test to see‹/›
The following table describes the value of this property.
Value | Description |
---|---|
normal | White space sequences will be folded into a single space. Newline characters will appear where the line box needs to be filled. This is the default value. |
nowrap | Text will not wrap, and text will continue on the same line until the <br> tag is encountered. |
pre | Preserve white space sequences. Lines are only broken at the preserved newline characters. It is similar to the <pre> tag in HTML. |
pre-line | Merge white space sequences but preserve newline characters. |
pre-wrap | Preserve white space sequences. The newline character will appear at the preserved newline and any place that fills the line box. |
initial | Set this property to its default value. |
inherit | If specified, the associated element adopts the white of its parent element-The value of the space property. |
white-The compatibility of the space property of the browser, the numbers in the table below represent the minimum version number of the browser that supports this property; all mainstream browsers support this property.
|
Warning:pre-line Firefox 3.5, Safari 3.0 and Opera 9.5The value pre is not supported in earlier versions. Value pre-line, pre-wrap and inherit in Internet Explorer 7and earlier versions do not support.
Please refer to the following tutorials:HTML text formatting.
Related properties:letter-spacing,word-spacing.