The white-space property defines the usage of white space in a text line and how the white space is to be handled.

The white-space property contains following information:

  1. value: normal, pre, nowrap, pre-wrap, pre-line or inherit;
  2. initial: normal;
  3. applies to: all elements;
  4. inherited: yes;
  5. percentages: N/A;
  6. media: visual;
  7. computed value: as specified.

White-space property's values have following meanings:

  • value normal lets browsers determine how to collapse sequence of white space and how to break lines;
  • value pre prevents browsers from collapsing sequence of white space; lines may be only broken at newline characters;
  • value nowrap lets browsers collapse white space normally but prevents line breaks within text;
  • value pre-wrap prevents browser from collapsing white space; lines may be broken at the newline characters and to fill line boxes;
  • value pre-line directs browsers to collapse white space while line breaks in the same manner as pre-wrap value.

To learn more how white-space in CSS works please refer to CSS advanced chapter.

Example

CSS white-space property example:

 

›› go to examples ››