How to show line breaks in HTML with ‘\n’?

Spread the love

Sometimes, we want to show line breaks in HTML with ‘\n’

In this article, we’ll look at how to show line breaks in HTML with ‘\n’.

How to show line breaks in HTML with ‘\n’?

To show line breaks in HTML with ‘\n’, we set the white-space style.

For instance, we write

white-space: pre-line;

to show line breaks when there’re line break \n characters.

And we write

white-space: pre-wrap;

to show line breaks when there’re line break \n characters and tabs \t characters.

Conclusion

To show line breaks in HTML with ‘\n’, we set the white-space style.

Leave a Reply

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