Should I still follow the XHTML rules? | SoloLearn: Learn to code for FREE!


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.

4/20/2018 3:03:27 PM


4 Answers

New Answer


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>.


Thanks. Really helpful


The first book I read for web development is about XHTML and I am getting used to its syntax. Anyway thanks man.


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)