Text inside div not showing multiple white spaces between words

Try:

white-space: pre-wrap;

This does 2 things that can help others:

  1. Keeps spaces as you want.
  2. Wraps text so that if it is too long it remains clean inside a container.

You could also use CSS to add styling like a <pre> tag. Use

  div#where-you-want-the-whitespace {
      white-space: pre;
  }

That is how html works. Whitespace is collapsed. Look at the way your question is displayed to see an example.

To work around this, wrap your text in a <pre> tag, or use &nbsp; instead of space characters


Or add white-space:pre to the CSS for the div.

Tags:

Html

Css