Fandom

HTML & CSS Wiki

White-space

649pages on
this wiki
Add New Page
Comments0 Share

The white-space property is used in CSS and certain HTML elements. This property is used to to describe how white space inside the element is handled.


Values

  • normal - Sequences of white space are collapsed. Newline characters in the source are handled as other white space. Breaks lines as necessary to fill line boxes.
  • pre - Sequences of white space are preserved, lines are only broken at newline characters in the source.
  • nowrap - Collapses white space as for normal, but suppresses line breaks (text wrapping) within text.
  • pre-wrap - Sequences of white space are preserved. Lines are only broken at newline characters in the source and as necessary to fill line boxes.
  • pre-line - Sequences of white space are collapsed. Lines are broken at newlines in the source and as necessary to fill line boxes.


The following table summarizes the behavior of the values:

New lines Spaces and tabs Text wrapping
normal Collapse Collapse Wrap
pre Preserve Preserve No wrap
nowrap Collapse Collapse No wrap
pre-wrap Preserve Preserve Wrap
pre-line Preserve Collapse Wrap


HTML example:

<code style="white-space:pre;">codecodecodecodecode</code>


CSS example:

code { 
      white-space:pre; 
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.