I am trying to write a bunch of text onto a new document using document.write() and somehow need to format it to include line breaks.
For example:
document.write(Line 1);
document.write(Line 2);
I have tried including
, and it does not work. I have also tried document.writeln() and that also does not work.
From what I have found on the Internet, one (if not both) of those methods should have worked… :sick:
The alternative is to use a proper HTML line break - <br>
Thanks, using document.write(‘<pre>’) worked.
TriLLi
4
If you want to format document with line breaks than you need to put that text into element pre
example
<pre>
hello,
how are you
are you ok
</pre>
sow when you are using document.write do it with this logic
document.write('<pre>');
document.write('hello\\r\
from here \\r\
');
document.write('</pre>');