How to use a new line(\n) in string and rendering the same in HTML and CSS?

Spread the love

To use a new line(\n) in string and rendering the same in HTML and CSS, we set the white-space property.

For instance, we write

body {
  white-space: pre-wrap;
}

to apply the white-space: pre-wrap; style to the body element to make new line character render as a new line in HTML.

Leave a Reply

Your email address will not be published. Required fields are marked *