Should I still follow the XHTML rules? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Should I still follow the XHTML rules?

XHTML is old I think compared to the newer version HTML5. Should I still use <br /> or stick to the <br>? Is it still worth it to write markups in that way? Suggestion might help my confused brain.

20th Apr 2018, 3:03 PM
Alquen
Alquen - avatar
4 Answers
+ 1
XHTML is based on XML, while HTML is not. In XML/XHTML, writing it as <br /> would be mandatory, but in HTML, <br> is preferred. <br /> is allowed in HTML too, but it's purely optional (probably it's there so HTML can be generated by XML tools). Nobody really uses XHTML though and nobody really ever did, so if you are writing your HTML by hand, you're better off using <br>.
20th Apr 2018, 3:17 PM
Schindlabua
Schindlabua - avatar
+ 2
Thanks. Really helpful
20th Apr 2018, 3:33 PM
Alquen
Alquen - avatar
+ 1
The first book I read for web development is about XHTML and I am getting used to its syntax. Anyway thanks man.
20th Apr 2018, 3:23 PM
Alquen
Alquen - avatar
+ 1
I think the XHTML syntax is nicer too and I too write <br /> out of habit. It would be great if everyone were to write XHTML - there are benefits - but it sadly never took off because it would have required everyone to switch. (Imagine writing an XHTML website and you are including badly written HTML ads - your whole website would break)
20th Apr 2018, 3:32 PM
Schindlabua
Schindlabua - avatar