[Bug 12072] New: Comments before <!DOCTYPE html> should be forbidden

http://www.w3.org/Bugs/Public/show_bug.cgi?id=12072

           Summary: Comments before <!DOCTYPE html> should be forbidden
           Product: HTML WG
           Version: unspecified
          Platform: PC
               URL: http://dev.w3.org/html5/spec/syntax#comments
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: HTML5 spec (editor: Ian Hickson)
        AssignedTo: ian@hixie.ch
        ReportedBy: xn--mlform-iua@xn--mlform-iua.no
         QAContact: public-html-bugzilla@w3.org
                CC: mike@w3.org, public-html-wg-issue-tracking@w3.org,
                    public-html@w3.org


<!--comments before--><!DOCTYPE html>

should be forbidden, because

a) it triggers quirksmode in IE6, IE7, IE8 and IE9;
b) "HTML5 compliant quirksmode" isn't needed & is against HTML5's spirit
    Valid HTML5 shouldn't trigger quirks in mayour browsers!
c) it is a gotcha to authors;  Confusion isn't hard to locate.[1][2]
    Even a check of the 10 first pages on Philip Taylor's no-quirks list
revealed
    that one of them <!---> before DOCTYPE; [3]
d) there is an alternative: <!---> *after* the DOCTYPE;
e) it is a hindrance to Polyglot Markup; 
    * <!---> before DOCTYPE is OK in 'application/xhtml+xml', 
      ( as long as it follows *after* a possible XML declaration) ;
    * Thus e.g.  IE9 in 'application/xhtml+xml' mode gets no problems.
    * But the same page in text/html mode will cause IE quirks;
f) it promotes proprietary syntax; Proprietary code such as
    <!--[if !IE]><![endif]-->
    <!DOCTYPE html> 
            and
    <!---><!DOCTYPE html>
    <meta http-equiv="X-UA-COMPATIBLE" content="IE=Edge" />
    is the only way to have <!---> before DOCTYPE w/o getting IE quirks

POSSIBLE COUNTER ARGUMENTS:

* Claim: "There is a need to trigger quirks mode in IE6 an donly in IE6!"

Whether there is such a need, is a question in itself. But, for now, assuming
there is such a need, then:

ANSWER 1: 
   To forbid comments before the DOCTYPE does not hinder authors from still
using them. It just won't validate anymore. HTML5 defines no-quirks as the
default mode. There are many syntaxes that are forbidden in HTML5, but which
still triggers *no-quirks* (a.k.a. standards) mode in HTML5 parsers. (For
example, the XML declaration doesn't trigger quirks mode in a valid HTML5
parser.)  Forbidding comments before the DOCTYPE will be no different.

ANSWER 2: 
   For XHTML pages, there is one, common answer to that problem: use the XML
declaration before the DOCTYPE. (For examples of that kind of advice, see
http://www.gunlaug.no/contents/wd_additions_16.html and
http://www.456bereastreet.com/archive/200904/using_an_xml_declaration_triggers_quirks_mode_in_ie_6/
) 
This will trigger quirks-mode in IE6, but not in IE7, IE8 or IE9. (But note
that even if XML declaration was permitted, it would still have to be forbidden
to use comments *between* the XML declaration and the DOCTYPE, as this causes
quirks-mode in IE7, IE8 and IE9.)

ANSWER 3:
    Authors will develop other methods for triggering quirks-mode in IE6. HTML5
should nevertheless not promote quirks-mode. 

References:
    [1]
http://stackoverflow.com/questions/941100/can-html-comments-appear-before-the-doctype-declaration
    [2]
http://stackoverflow.com/questions/2770392/html-doctype-setting-ie-quirks-mode
    [3] http://philip.html5.org/data/doctypes.html#HTML5_non-quirks

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Tuesday, 15 February 2011 03:09:47 UTC