For loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

For loop

In the example given by Solo learn, they used "document.write(i + "<br/>)", however when I tried to use (i + "<br>") I've got the same answer. If those two are correct, why they use backslash?

22nd Feb 2020, 4:18 AM
Yan Yan
Yan Yan - avatar
2 Answers
+ 5
Moshi <br> is for HTML5 <br/> and <br /> are for XHTML however the better way is written with and back slash, <br /> is always preferable https://www.w3.org/TR/xhtml1/#C_2 So both are alternative ways to write tag and used for same purpose.
22nd Feb 2020, 4:51 AM
DishaAhuja
DishaAhuja - avatar
0
Thank you!
22nd Feb 2020, 5:27 AM
Yan Yan
Yan Yan - avatar