[whatwg] self-closing tags in html5
kornel at geekhood.net
Fri Dec 31 08:33:40 PST 2010
On Fri, 31 Dec 2010 07:18:52 -0000, Ian Hickson <ian at hixie.ch> wrote:
> For example, markup such as the following is sadly common:
> <p/>Hello world!</p>
> I have therefore not changed the spec in response to this request.
I've checked www.dotnetdotcom.org dataset looking for <tag…/>…</tag>,
excluding <script> and comments.
You're right about HTML elements — constructs such as <br/></br>, <a
href=/></a> and <div/></div> are common (7% of pages have at least one
such construct!), and almost every HTML element is misused like this (even
<body/>, <style/>, <b/>).
However, for non-HTML elements the story is completely different.
There are very few pages (< 0.01%) that have this error on non-HTML
elements. I've found few cases of <personname productid="常凸显" w:st="on"
/>常凸显</personname /> and <Actinic:COOKIECHECK/></Actinic:COOKIECHECK/>,
which don't seem to be used on client-side anyway.
Parsing of non-HTML elements is not interoperable between IE and non-IE
browsers. IE already supports self-closing syntax on prefixed elements,
but other browsers don't:
and IE cannot properly parse unknown non-prefixed elements, except when
(relatively new) workaround is used (http://ejohn.org/blog/html5-shiv):
With such interoperability problems, I think it's unlikely that there are
many pages that rely on particular parsing of non-HTML elements,
especially one that disagrees with XML.
I think HTML5 can specify that a fixed set of old HTML elements has to be
closed according to HTML rules, but all other elements support
self-closing syntax like XML.
regards, Kornel Lesiński
More information about the whatwg