white-space

The white-space CSS property sets how white space inside an element is handled.

Example

Initial value normal
Applies to all elements

Syntax

  
white-space: nowrap;
  

Values

Sequences of white space are collapsed. Newline characters in the source are handled the same as other white space. Lines are broken as necessary to fill line boxes.
Collapses white space as for normal, but suppresses line breaks (text wrapping) within the source.
Sequences of white space are preserved. Lines are only broken at newline characters in the source and at
elements.
Sequences of white space are preserved. Lines are broken at newline characters, at
, and as necessary to fill line boxes.
Sequences of white space are collapsed. Lines are broken at newline characters, at
, and as necessary to fill line boxes.
The behavior is identical to that of pre-wrap, except that: Any sequence of preserved white space always takes up space, including at the end of the line. A line breaking opportunity exists after every preserved white space character, including between white space characters. Such preserved spaces take up space and do not hang, and thus affect the box’s intrinsic sizes (min-content size and max-content size).

Browser support

white-space11215.541
break-spaces7679696213.1
nowrap11215.541
pre1121641
pre-line1123.589.53
pre-wrap1123883
svg_support123610
textarea_support112365.541

We use cookies to improve your experience. Learn more in our Privacy policy.

×