W3C home > Mailing lists > Public > public-html-comments@w3.org > December 2010

Re: [whatwg] self-closing tags in html5

From: William F Hammond <hammond@csc.albany.edu>
Date: Fri, 31 Dec 2010 13:59:33 -0500
To: Ian Hickson <ian@hixie.ch>
Cc: whatwg@whatwg.org, public-html-comments@w3.org
Message-ID: <i7r5cxbwfe.fsf@hilbert.math.albany.edu>
Ian Hickson <ian@hixie.ch> writes:

> On Sat, 25 Sep 2010, William F Hammond wrote:
>>
>> In the spec at 8.1.2.1 (6) (for the text/html serialization):

The section number refers to the W3C version at
http://www.w3.org/TR/html5/

>>    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>

My comment about cognitive dissonance in
http://lists.w3.org/Archives/Public/public-html-comments/2010Sep/0026.html
is also relevant here.

The parsing rules of section 8.2 (W3C version) in the html5 spec do
adequately separate the cases.

So as I read those rules (on September 25):

1. your example above would be parsed as a non-empty paragraph

2. <a href=http://example.foo/>an example</a>

   would be parsed with the '/' as part of the url

3. <a id="mylabel"/>  OR  <a id=mylabel />

   would be understood as self-closing under section 8.2 but then
   handled as regular open tags.  That is cognitive dissonance.  Then
   because <a> has transparent content, the nonsense can be propogated
   through several paragraphs.

Why not re-write 8.1.2.1 (6) as follows:

Then there may be a single U+002F SOLIDUS character (/).  This
character has no effect on void elements.  On foreign elements it
marks the start tag as self-closing.  On non-void HTML elements it
marks the start tag as self closing if it is immediately preceded by
whitespace or by a single instance of one of the two markup quoting
characters U+0022 or U+0027; otherwise it has no effect, and the
start tag is not understood as self-closing.

Without language of this type the specification has not actually
covered the example you cited, i.e.,

             <p/>Hello world!</p>  ,

where the <p/> should not be self-closing

                                    -- Bill
Received on Friday, 31 December 2010 19:00:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 1 June 2011 00:14:05 GMT