HTML5 allows either <br>
or <br/>
. Does the W3C specification or any other authority state whether one is preferable over the other? Is there a good reason (or reasons) to use one over the other if adherence to XHTML is irrelevant?
HTML5 void elements' ending / is optional, but is it preferable?
524 views Asked by at. At
2
In HTML5 compliant browsers, this makes no difference. I think you would have difficulty citing any resource which preferred
<br />
over<br>
, slash-trailing image tags, or even closing<path>
elements. It is most likely preferable not to have the trailing slash simply because the document takes just that much longer to fetch from the webserver and for the HTML interpreter to serialize (as minuscule a time differential as this actually provides). In addition, all HTML5 compliant browsers strip these characters in runtime, which is evident when you callouterHTML
on an HtmlElement.EDIT: I also think that if there was any difference or adherance to a standard to preserve, it would be reflected on the w3c page: https://www.w3.org/wiki/HTML/Elements/br
However, I feel as though it is worth mentioning that browsers that are not compliant with HTML5 standards (mostly earlier, unsupported versions of IE) demand a trailing slash to render the element.