W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2007

[whatwg] HTML syntax: comments before doctype and doctype sniffing

From: Philip Taylor <excors+whatwg@gmail.com>
Date: Mon, 18 Jun 2007 22:00:31 +0100
Message-ID: <ea09c0d10706181400i64ed6b23wda67f82000e094df@mail.gmail.com>
On 18/06/07, Ian Hickson <ian at hixie.ch> wrote:
> On Sun, 3 Dec 2006, Simon Pieters wrote:
> > Also, as an additional constraint in the syntax section, the entire
> > doctype probably should (or must) be within the first 1024 bytes,
> > because AFAIK browsers generally only sniff for the first 1024 bytes,
> > and if they don't find the entire doctype within that then you get
> > quirks mode.
>
> I couldn't reproduce that.

In Firefox 2:

javascript:s='<?>';for(i=0;i<1006;++i)s+='
';window.location='data:text/html,'+s+'<!doctype
html><script>document.write(document.compatMode)</script>'

javascript:s='<?>';for(i=0;i<1007;++i)s+='
';window.location='data:text/html,'+s+'<!doctype
html><script>document.write(document.compatMode)</script>'

The first produces CSS1Compat, the second BackCompat. As far as I can
tell, Firefox requires the doctype to be found when parsing [using
standards-mode rules] the first 1024 characters (not bytes) from the
first non-whitespace character, and then it reparses the whole
document in quirks mode if necessary.

-- 
Philip Taylor
excors at gmail.com
Received on Monday, 18 June 2007 14:00:31 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:56 UTC