English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
CSS White-space Whitespace AttributeUsed to specify how the content in an element is displayed. It is used forHandling Whitespace Inside Elements.
There are many whitespace values that can be used to display the content inside elements.
Value | Description |
---|---|
normal | This is the default value. Under this value, line breaks are made when necessary. Whitespace sequences are collapsed into a single whitespace. |
nowrap | Whitespace sequences are collapsed into a single whitespace. Under this value, the text will never wrap to the next line, and it will only be broken using the tag. |
pre | Whitespace is retained by the browser. It is similar to the html pre tag. The text will only be wrapped at line breaks. |
pre-line | Whitespace sequences are collapsed into a single whitespace. The text is wrapped and line-breaks are made online when necessary. |
pre-wrap | Whitespace is retained by the browser. The text is wrapped and line-breaks are made online when necessary. |
initial | It sets this property to its default value. |
inherit | It inherits this property from its parent element. |
<!DOCTYPE html> <html> <head> <style> p { white-space: nowrap; } </style> </head> <p> Write some text. Write some text. Write some text... Write some text. Write some text. Write some text... Write some text. Write some text. Write some text... Write some text. Write some text. Write some text. Write some text. Write some text. Write some text... </p> </html>Test and See‹/›