Preserve line breaks when getting text from a textarea
Category: html-and-css
By: jeremy-one
The first easiest option is to simply style the element you're inserting the text into with the following CSS property:
white-space: pre-wrap;
By: jeremy-two
To help visualize \n
in the web browser use you can add:
white-space: pre-line
Check dev tools and see and toggle the above class to see spaces added and removed.