English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Basic Tutorial

CSS Box Model

CSS3Basic Tutorial

CSS Reference Manual

CSS @rules (RULES)

CSS White-space(Whitespace)

CSS White-space Whitespace AttributeUsed to specify how the content in an element is displayed. It is used forHandling Whitespace Inside Elements.

CSS Whitespace Values

There are many whitespace values that can be used to display the content inside elements.

ValueDescription
normalThis is the default value. Under this value, line breaks are made when necessary. Whitespace sequences are collapsed into a single whitespace.
nowrapWhitespace 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.
preWhitespace is retained by the browser. It is similar to the html pre tag. The text will only be wrapped at line breaks.
pre-lineWhitespace sequences are collapsed into a single whitespace. The text is wrapped and line-breaks are made online when necessary.
pre-wrapWhitespace is retained by the browser. The text is wrapped and line-breaks are made online when necessary.
initialIt sets this property to its default value.
inheritIt inherits this property from its parent element.

CSS White-space Online Example

<!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‹/›