[whatwg] Comment Syntax and Parsing

Lachlan Hunt lachlan.hunt at lachy.id.au
Sat Jan 21 20:57:23 PST 2006


Hi,
   This is somewhat in response to Ian's recent article about comment 
parsing [1].

Firstly, Ian, could you please clarify what exactly made you change your 
mind about this issue, after seven years of pushing (mostly) proper SGML 
comment handling and which eventually resulted in 5 implementations 
(Mozilla, Safari, Opera, Konqueror and Prince)?  I assume, of course, 
this now means that all of those browsers will soon, if not already, be 
removing such support?

Secondly, what will now be defined as a conforming comment syntax for 
use in a document?  Ignoring parsing requirements, is it safe to assume 
that HTML will borrow from the stricter XML comment syntax, which start 
with '<!--' and end with '-->' and does not contain '--' anywhere in 
between?

In other words:
<!-- valid comment -->
<!-- invalid -- comment -->
<!-- invalid -- -- comment --> (though, valid in HTML4)

That seems like the most backwards compatible method, it remains 
compatible with the HTML4 syntax and is actually the way most good 
tutorials teach authors to write comments.

What about the empty comment declaration: <!> ?  I've never seen anyone 
use it (except in test cases), and I tested it with your new live DOM 
viewer tool and these were the results:

http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0A%3Ctitle%3Etest%3C/title%3E%0A%3Cp%3Etest%3C%21%3Etest%3C/p%3E

Firefox 1.5.0.1: Treated as comment
IE 6:            Rendered the document properly, though the DOM view
                  showed nothing but: #comment: CTYPE ht
Opera 9/Win:     CRASHED!
Opera 9/Mac:     CRASHED!
Opera 8.5/Mac:   Ignored (not shown in DOM view)
Safari 2.0.3:    Ignored (not shown in DOM view)

As a result, and because nothing is gained by using it, it too should be 
considered non-conformant, but should be parsed as a comment, like 
Firefox does.

[1] http://ln.hixie.ch/?start=1137799947&count=1

-- 
Lachlan Hunt
http://lachy.id.au/




More information about the whatwg mailing list