It is not necessary to include the slash at the end of the element, although this is allowed in the case of null elements , to the joy of fans by XML:
[ About syntax for opening tags ]
6. Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single "/" (U + 002F) character. This character has no effect on void elements, but on foreign elements it marks the start tag as self-closing.
Free translation:
If the element is one of the null elements, or if it is a foreign element, then a single "/" character (U + 002F) can be included. This character has no effect on null elements, but on foreign elements it marks the opening tag as self-closing.
So in HTML5 both options below are valid * for the meta
tag:
<meta charset=utf-8>
<meta charset=utf-8 />
(I personally find the first option preferable because it is cleaner.)
The spec text you quoted says:
Void elements only have a start tag; end tags must not be specified for void elements
That is:
Null elements have only one opening tag; closing tags should not be used in null elements.
This means that a closing tag </meta>
is invalid, not that <meta />
is invalid.
In XML, or XHTML, when you write something like <img />
, this equals <img></img>
. The bar at the end is just a shortcut to indicate to the parser that the tag is being closed, without content, since in XML all the tags must be closed. HTML5 is not XML, and does not work in the same way.
* The W3C validator says that HTML5 support is experimental, but I believe that for this case the result is reliable