#white-space

Defines how the element's white space is handled.

默认属性 white-space: normal;

Sequences of spaces are combined into one.
Line breaks are ignored.
The text content is wrapped.

white-space: nowrap;

Sequences of spaces are combined into one.
Line breaks are ignored.
The text content is not wrapped and remains on a single line.

white-space: pre;

The white space is exactly preserved.

  • Sequences of spaces are preserved
  • Lines break only on new lines and <br>

white-space: pre-wrap;

The white space is mostly preserved.

  • Sequences of spaces are preserved
  • Lines break on new lines, <br>, but also when reaching the end of the element

white-space: pre-line;

Only new lines are preserved.

  • Sequences of spaces are combined into one
  • Lines break on new lines, <br>, but also when reaching the end of the element