document.write(); indent problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

document.write(); indent problem

This code is printed right night to each other: document.write("Hello"); document.write("World"); How do I get them to indent so they're each on separate lines?

23rd Nov 2016, 1:56 PM
Caleb Jore
Caleb Jore - avatar
4 Answers
+ 4
I've already tried combining them into one document.write and using \n, but it didn't work.
23rd Nov 2016, 2:00 PM
Caleb Jore
Caleb Jore - avatar
+ 4
Thanks so much guys! Check out Interest Calculator 2.1 in my codes.
23rd Nov 2016, 3:13 PM
Caleb Jore
Caleb Jore - avatar
+ 3
document.write("Hello"); document.write("<br/>"); document.write("World"); <br/> is used to break line in html. You are using document.write means it will write your data in html webpage, thatswhy \n is not working. \n work on console in browser.
23rd Nov 2016, 2:26 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 1
:) Try to add document.write("<br/>"); between the lines.
23rd Nov 2016, 2:01 PM
Ondřej Doněk
Ondřej Doněk - avatar