[RESOLVED]Difference in <br> and <br /> ?

I am developing a site in ASP.NET MVC and wondering which one to use for line break?

Is <br> correct OR <br /> ?

I see based on google search that <br> is for HTML only and <br /> is for XHTML.

In order to create a cross-browser compatible website, which one to use?

<br> is the current usage. Since it has no children, then there’s no need for it to have a end tag or to be a self closing tag.

Also, XHTML is dead.

<br> is sufficient
<br /> on the other hand is an XHTML (and therefore XML) valid element, observing the XML rule that all elements should have a corresponding closing element or use an inline-closing slash.

<br /> is only used in XHTML programming. For example

HTML – Hello World <br> Bye

XHTML – Hello World <br> Bye <br />

It’s just a closing tag.

You will have fewer problems if you use <br /> in a Razor View file as Razor likes tags to have matching closing tags or to be self-closed. Therefore I recommend using <br />.

Thank you everyone for your suggestions, I think I will go with <br />

Leave a Reply