In HTML5 is it still appropriate to close a <br> tag with <br />?
This obviously also applies to all other single tags. I realize this doesn’t actually affect how stuff works, but what is best practice here?
someLines of txt <br> // How you see a lot of people doing it
and then some <br /> // XHTML style! Should I still be doing this?
ow im not done yet.. <br> </br> // No one does this right? RIGHT?!
From the W3C specification for HTML:
The following is a complete list of the void elements in HTML:
area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbrVoid elements only have a start tag; end tags must not be specified for void elements.
Start tags consist of the following parts, in exactly the following order:
<character./character, which may be present only if the element is a void element.>character.From this it seems that we can use either
<br>or<br/>. However, the end tag</br>is not valid, so don’t use<br> </br>.Running the following through the HTML Validation Service indicates as much.
So use either
<br>or<br/>, just make sure you use them consistently.Edit: As noted by Brad,
<br />is also valid XHTML, so perhaps it is best to choose this form.