NewLine escape character not working

This has nothing to do with JavaScript. In HTML, all whitespace (including newlines) is collapsed and treated as a single space.

To do a line break in HTML:

  • Use <br>
  • Or organize your text into paragraphs with <p>...</p>, etc.)
  • Or if you’re outputting some form of formatted text (like code), you can do that in a <pre>...</pre> element (or any element with the white-space: pre, white-space: pre-wrap, or white-space: pre-line style applied to it).

Leave a Comment