Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 3
\n doesn't work
I am running this code, but it outputs everything on the same line. Why \n doesn't work here? document.write ('Line 1\n Line 2');
8 Answers
+ 12
Yeah. IIRC, HTML line breaks are done via <br/>. You may use those instead, since that's how HTML documents are parsed.
+ 4
Thanks! With <br/> it works fine!
+ 3
[meta] <pre> tags don't "interfere" with text so literal carriage returns are okay there. Hatsy Rei has the right context for what you're doing.
+ 3
PGameYT no... you use \n in javascript too... like alert:
alert("line 1 \n line2")
+ 3
You can use \n only in alert and console methods.
0
simply use <br> in code
document.write('Line 1 <br> Line2');
0
oh I know the console stuff but I nevr knew you could do that in J.S. Thats cool thanks for the advice. 👍👍👍
- 2
\n is only us ed in C