How do you do a line break in java, I have a run-on sentence? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do you do a line break in java, I have a run-on sentence?

I'm a c++ programer messing with js, and iv have tried \n and it dont break the two sentences up, what I want is: -Math problem1 -Math problem2 https://code.sololearn.com/Wp6uhcK5rY5N/?ref=app

5th Mar 2018, 6:08 PM
Baric
Baric - avatar
4 Answers
+ 2
When you write to the page, you're not writing JavaScript; you're writing HTML. \n is a special "line feed" character that doesn't create a line break in the browser's rendering of the HTML. It WILL create a line break in the HTML file itself, but the browser doesn't take this into consideration when it renders out the markup. Thus, the br tag is required. Disclaimer:- I searched stackoverflow and found out why '\n' doesn't works? The question is answered by BraedenP
5th Mar 2018, 7:01 PM
Vikash Pal
Vikash Pal - avatar
+ 18
"\n" //works in java
5th Mar 2018, 6:13 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 5
or use "<br>";
5th Mar 2018, 6:15 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
0
thanks guys Idk why \n wasnt working but <br> solved it
5th Mar 2018, 6:36 PM
Baric
Baric - avatar