Little Web Hut

CSS 2.1 Reference: white-space Property

CSS white-space Property
Syntax
selector {white-space: value;}
  • value is specified by using one of the following keywords: normal, pre, nowrap, pre-wrap, pre-line, or inherit.
Usage

The white-space property is used to control how white spaces are handled within the element.

This property is specified by using a keyword according to the syntax shown above.


CSS Example: The white-space properties are set using 5 different keyword values
  #tst1 {white-space: normal;}
  #tst2 {white-space: pre;}
  #tst3 {white-space: nowrap;}
  #tst4 {white-space: pre-wrap;}
  #tst5 {white-space: pre-line;}
Test It HTML StyleTest It XHTML StyleTest It HTML5 Style

Keywords
  • normal - Multiple white spaces will collapse into a single white space. Text will automatically word wrap. Line breaks are suppressed.
  • pre - White spaces are not altered. Text will NOT automatically word wrap. Line breaks will force word wrap.
  • nowrap - Multiple white spaces will collapse into a single white space. Text will NOT automatically word wrap. Line breaks are suppressed.
  • pre-wrap - White spaces are not altered. Text will automatically word wrap. Line breaks will force word wrap.
  • pre-line - Multiple white spaces will collapse into a single white space. Text will automatically word wrap. Line breaks will force word wrap.
  • inherit - The inherit keyword is used to specify that the value for this property should be taken from the parent element. If inherit is used with the root element, then the initial value for this property will be used.
Applies To All elements
Inherited Yes
Initial Value normal


white-space Property Examples
Test It HTML StyleTest It HTML StyleTest It HTML5 StyleThe white-space properties are set using 5 different keyword values.