[whatwg] self-closing tags in html5

On Sat, 25 Sep 2010, William F Hammond wrote:
>
> In the spec at 8.1.2.1 (6) (for the text/html serialization):
> 
>    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
>    SOLIDUS character (/).  This character has no effect on void
>    elements, but on foreign elements it marks the start tag as
>    self-closing.
> 
> It would be better to allow self-closing tags on all de facto empty
> elements, foreign or not and defined-empty or not.

In 
http://lists.w3.org/Archives/Public/public-html-comments/2010Sep/0027.html 
you further clarify "de facto empty" as meaning:

| A defacto empty element is an element that is either defined-empty in
| the document type definition OR any element in the current document
| instance that has no content.

While syntactic sugar to make "<foo/>" equivalent to "<foo></foo>" even 
for elements that are not void elements would probably be quite popular, 
it is unfortunately incompatible with legacy content. It turns out that 
there is a large amount of content that includes "/" characters in 
positions that appear to be the end of the start tag but that do not 
intend to have the browser close the element immediately.

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.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Thursday, 30 December 2010 23:18:52 UTC