Self-closing tags (void elements) in HTML5

There is no consensus on best practice, and according to the author of the spec, Ian Hickson, it does not matter.


Closing the tag with a slash is a more explicit way of denoting that it is not meant to have a closing tag.


Mostly it depends if you want to go the XML route or not. Both should render correctly, as the HTML5 spec does not require self-closing tags - their only reason is that the document is then valid XML.

The easier way is to probably just write then without the self-closing "/", unless there's a specific need to get the markup parsed as XML - in that case you also need

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >

Google suggests in its style guide: do not close void elements.

HTML5 (HTML syntax) is preferred for all HTML documents ... Although fine with HTML, do not close void elements

Personally I've gotten used to closing tags with a slash, and find that /> helps me to recognize that the tag will not have a closing tag.