Which CSS white-space Property Values Preserve Space?

Find out which CSS white-space property values preserve spaces

This following CSS white-space property values preserve spaces:

  • pre
  • pre-wrap
  • break-spaces

This means that when the CSS white-space property is set to any of these values, spaces won't be collapsed or removed (which might be the case when the property is set to a collapsible white-space value).

Consider for example the following, where spaces are preserved:

<span>foo</span> bar
span { border: 1px solid orange; }
span::after { content: ' '; white-space: pre; }

This would result in two spaces after "foo" (as opposed to one, which would be the case if the white-space property was set to a collapsible value).

Hope you found this post useful. It was published . Please show your love and support by sharing this post.