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

On 18/06/07, Martin Payne <martin-bulkmail at martinpayne.co.uk> wrote:
> Philip Taylor wrote:
> > 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.
> Not for me it doesn't (Mozilla/5.0 (X11; U; Linux i686; en-US;
> rv: Gecko/20070603 Fedora/ Firefox/ Both
> render in standards mode for me.

Hmm, that might have been some unfortunate line wrapping - it's
probably better to write:



where each should be one line with no spaces. Then I get the
CSS1Compat/BackCompat difference when just copying those into the
location bar, in "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:
Gecko/20070515 Firefox/" and "Mozilla/5.0 (X11; U; Linux i686;
en-US; rv:1.9a6pre) Gecko/20070618 Minefield/3.0a6pre".

(IE7 and Opera 9 don't appear to have any limit on how early the
doctype should appear.)

Philip Taylor
excors at gmail.com

Received on Monday, 18 June 2007 14:42:46 UTC