Step 6 of 8.1.2.1 Start tags of the HTML5 spec says that void elements may have a single /
character. I think this is so it's easier to migrate sites that are XHTML over to HTML5.
What's the best practice?
E.g., if I'm making a website with HTML5 (<!DOCTYPE html>
), which should I do?
without the slash
<meta http-equiv="content-type" content="text/html; charset=utf-8">
with the slash
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
If both render correctly on all browsers, then I'm assuming (1) without the slash is the way to go since it's more HTML5.
These elements are called empty or void and only have a start tag since they can't have any content. They must not have an end tag in HTML. The void elements in HTML 4.01/XHTML 1.0 Strict are area , base , br , col , hr , img , input , link , meta , and param .
↑ The full list of valid self-closing tags in HTML5 is: area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, and wbr.
A void element is an element whose content model never allows it to have contents under any circumstances. Void elements can have attributes. 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 , wbr.
Void elements only have a start tag; end tags must not be specified for void elements.
There is no consensus on best practice, and according to the author of the spec, Ian Hickson, it does not matter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With