<br> or <br /> | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

<br> or <br />

Does it matter which way the void elements are written? Such as <hr> and <hr /> or <input> and <type /> I see examples use both alternating, and even in testing, I see no differences in code execution. What's the relevance? https://code.sololearn.com/WYzmLK7oEeFv/?ref=app

2nd Jun 2018, 9:43 PM
Andre Daniel
Andre Daniel - avatar
7 Answers
+ 9
Being on the other side of the barricade, I see a difference when parsing a website. Parsers consider <br> and <br/> tags as different, usually. Not to mention they are often confused seeing those tags and classifying them wrong :)
2nd Jun 2018, 9:51 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
Andre Daniel Some parsers may read <br> as an open tag and <br/> as closing tag. If you parse a web based on this rule, you might get unexpected results, as "the line break" is a single-type tag, no matter the actual writing.
3rd Jun 2018, 6:35 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
i don't think there is a difference... its like the bold tag: you can write <b> or <strong>
2nd Jun 2018, 9:51 PM
Eli Ben Shimon
Eli Ben Shimon - avatar
+ 2
there are no visual differences, its something like alert(""); and alert("") the computer will read it as <br/> but you can just type <br> if you want
2nd Jun 2018, 10:17 PM
Roel
Roel - avatar
+ 1
Roel in some languages, alert("") will return an error since there is no semicolon (;), such as Java. 😅
2nd Jun 2018, 10:20 PM
Andre Daniel
Andre Daniel - avatar
+ 1
yes, but javascript wont, as it is way more flexible than java :)
2nd Jun 2018, 10:21 PM
Roel
Roel - avatar
0
Kuba Siekierzyński so what do parsers classify them as, in other words, what are the visual differences?
2nd Jun 2018, 10:10 PM
Andre Daniel
Andre Daniel - avatar