\n don't do anything | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

\n don't do anything

hi guys. Tried today to write some text paragraph and i was using \n to make text go to new line, but nothing happened.

23rd Jul 2017, 7:16 PM
Sergey Kozinecs
Sergey Kozinecs - avatar
4 Answers
+ 5
Whitespace is compressed when the html page is rendered. Instead, you can use <br> to move to the next line. (It will insert a 'line break')
23rd Jul 2017, 7:50 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
code?
23rd Jul 2017, 7:18 PM
The Coding Sloth
The Coding Sloth - avatar
+ 2
Text passed to the document.write() method is put into the DOM like HTML you will therefore need to use the <br />tag not /n as this just create white space which will be ignored. var message = "Hello <br /> my name..." document.write(meaaage);
23rd Jul 2017, 9:34 PM
josh mizzi
josh mizzi - avatar
+ 1
var message = "Hello \n My name is Sergei"; document.write(message); and as result in browser all in 1 line.
23rd Jul 2017, 7:23 PM
Sergey Kozinecs
Sergey Kozinecs - avatar