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

self-closing tags in html5

From: William F Hammond <hammond@csc.albany.edu>
Date: Sat, 25 Sep 2010 22:24:49 -0400
To: whatwg@whatwg.org
Cc: public-html-comments@w3.org
Message-ID: <i7k4m9tf66.fsf@hilbert.math.albany.edu>
In the spec at (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

It would be better to allow self-closing tags on all de facto empty
elements, foreign or not and defined-empty or not.  That is: for any
tag name "foo", the markup "<foo/>" should be equivalent to
"<foo></foo>".  If "foo" is a defined-empty element in the html
name space, then all of "<foo>", "<foo/>", and "<foo></foo>" should
be equivalent.

This is better because (1) authors are given more choice and (2) DOM
building is simplified.

For example, while it is true that major browsers seem to treat "<p/>"
as an open tag, the relevant question for backward comptatibility is
whether anyone has been relying on the idea that "<p/>" can be used to
begin a non-empty paragraph.

                                    -- Bill

William F. Hammond                   Dept. of Mathematics & Statistics
hammond@albany.edu                            The University at Albany
http://www.albany.edu/~hammond/                    Albany, NY (U.S.A.)

P.S.  It is true that the W3C HTML 4 & 4.01 specifications formally
(and unwisely for text/html) enabled full SHORTTAG in the accompanying
SGML declaration.  So, for example,

     <p/Hello guys!  This is text in
        a formally legal paragraph. /

is a correctly marked HTML-4 "p" element according to the
specification.  But there was no significant appearance of this markup
across the web in text/html.  (It is simple to modify the SGML
declaration for HTML 4 to disable this usage.)  A spec compliant
implementation of HTML 4 would, however, render the content of

     <p/>Hello guys!</p>

as ">Hello guys!".
Received on Sunday, 26 September 2010 02:25:44 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:26:26 UTC