Search within TutorialsPark

CSS white-space Property


To control the handling of whitespace and new lines.


Definition and Notes.

1. The CSS whitespace property is used to define the way white-space characters are processed when being laid out on the webpage.

2.Normally, browsers automatically collapses extra whitespaces and ignore new lines in HTML.


Syntax:

CSS white-space property. internetexplorer safari firefox opera chrome

View in Splitscreen»

Code-Editor:

Note-Do not confuse <pre> and <nobr> with white-space property

Property Values

Value Description
normal Removes all inherited values, its the default
nowrap Prevents browser from automatically wrapping the text.
pre Preserves all the spaces and new lines.
pre-wrap Whitespaces are preserved and text wraps to make line fit or when a line break is encountered.
pre-line Whitespaces are collapsed and text wraps to make line fit or when a line break is encountered.

Specifications

Specs Value
Name white-space
Value normal | nowrap | pre | pre-wrap | pre-line
Initial Value normal
Applies to Block level elements
Javascript syntax object.style.whiteSpace="nowrap"
Inherited No
Computed Value Same as declared Value
Browser Support internetexplorer safari firefox opera chrome


Related Examples.