White space in HTML gets ignored, unless it is a single character long. All additional white space fields, including line breaks, count as a single white space.

To ensure your displayed text stays the way you planned you must replace the white space with one of the following options, depending on the purpose of it:

  • use element <pre></pre> which stands for pre-formatted text that preserves white space and line breaks but also display text in fixed width font (usually Courier)
  • use no-break space character or &nbsp;
  • use one of the following characters, depending on need and character set applied:
    • ASCII space (&#x0020;)
    • ASCII tab (&#x0009;)
    • ASCII form feed (&#x000C;)
    • Zero-width space (&#x200B;)

Example

HTML example with white space inside the code:

 

›› go to examples ››