0

Newline Character does not work

https://code.sololearn.com/WBufZ22Fr82k/#js Check the code please and see how new line character and even space is not recognized in the compiler (at least not in the SOLO Learner compiler) I had to use the <br> tag to move the text to the next line. But I personally like the escape character \n for next line.

4th Nov 2019, 7:47 AM
Ahalya S B
5 Answers
+ 2
\n does not work in HTML (in HTML you would need to use <br/>, but you can still use \n with the alert function.
4th Nov 2019, 7:54 AM
Seb TheS
Seb TheS - avatar
+ 2
You can put the text inside a <pre></pre> block to display content with \n and spaces. If excessive typing doesn't bother you, you can use &nbsp; in place of a single space. This special character will not be collapsed into single space. But you'd have to deal with the extra work for typing &nbsp; just for typing a space.
4th Nov 2019, 8:55 AM
Ipang
+ 1
HTML automatically converts multiple spaces into 1 space.
4th Nov 2019, 8:05 AM
Seb TheS
Seb TheS - avatar
0
But I had spaces there in the code after the next line character as well. Will that not work as well? I had mentioned it as: "\n\n" + " "+"<TEXT_DISPLAYED>" Next line - agreed does not work. How about the space mentioned after the next line character and before the text?
4th Nov 2019, 8:02 AM
Ahalya S B
0
So, how do I give multiple spaces in case I have to?
4th Nov 2019, 8:07 AM
Ahalya S B