How to make newline with "\n" in html and not with "br" tag? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to make newline with "\n" in html and not with "br" tag?

29th Nov 2019, 5:03 PM
Andi Wahyu Khusnul Malik
Andi Wahyu Khusnul Malik - avatar
2 Answers
+ 3
You can't. Browsers ignore whitespace so toss them.
29th Nov 2019, 5:22 PM
John Wells
John Wells - avatar
0
The \n character is used to find a newline character. Can be done in JavaScript as in the example: var str = "Visit sololearn.\nLearn Javascript."; alert(str); result: Visit sololearn Learn Javascript. all browser support
30th Nov 2019, 12:05 AM
Ahmed Belkhodja