CSS White Space Property

White Space in CSS

The white-space CSS property describes how to show the content inside an element. This property is applied to manage a white space within an element.

Values of White-space Property

The following are the values that can be applied to the elements to show the content.

ValueDescription
normalThe normal value is the default value. The necessary text can be wrapped by using this value. The white space sequence will collapse into a specific white space.
nowrapThe white space sequence will be collapsed into one particular white space. The text can’t be wrapped to the next line by using this value and can be broken only by using the <br> tag.
preIn this value, whitespace is secured by a browser. This value is behaved like a <pre> html tag. The text will be wrapped only by using the line breaks.
pre-lineWhite space sequence will be collapsed into a specific white space. The text can be wrapped if necessary, and only when using the line breaks.
pre-wrapIn this value, whitespace is secured by a browser. The text will be wrapped only by using line breaks.
initialThis property can be set-up as a default value by using this value.
inheritIt can acquire the property from its parent element.

Example of White Space

Take a look on the following example of white space:

<!DOCTYPE html>
<html>
<head>
<style>
p
{
 white-space: pre;
}
</style>
</head>
<body>
<p>
Write any text..Write any text..Write any text..
Write any text..Write any text..Write any text..
Write any text..Write any text..Write any text..
Write any text..Write any text..Write any text..
Write any text..Write any text..Write any text..
</p>
</body>
</html>

Output:

CSS White Space