What throws Internet Explorer into quirks mode?
Asked Answered
G

4

17

I have created a webpage (http://www.snow4life.yum.pl) that was rendered properly in firefox, chrome etc. Of course dumb IE complicated things, because it enters quirk mode automatically, even though doctype is properly set and site goes through w3 validation (there is one error of missing some char, but file was cleared in hex editor). How can I stop ie from entering quirks mode ? Is there any way ?

Glandular answered 16/10, 2010 at 17:25 Comment(0)
J
27

Try killing all the whitespace before the DOCTYPE.

EDIT: There is an <feff> character which is a Unicode BOM signature at the start of the file. Since you may not have a text editor that can actually see that, try deleting the entire first line and paste over it with

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

And do NOT save the file with a BOM unicode signature. If this doesn't work, try a different text editor altogether.

Jevons answered 16/10, 2010 at 17:26 Comment(7)
Your site is in quirks mode in Firefox, too. There still is a whitespace in front of the doctype.Shaving
damn it no matter what I paste there, ie still in quirks mode. Even with copied/pasted templates from w3c. wtfGlandular
the best part : I've saved main page of w3c.org and renamed it as my template. W3C validator shows 40 errors !! And of course - quirks mode.Glandular
I'm using vim now, clear templates from w3c and still the same. I'm just pasting the code to vim -> save'as -> base.html and then send it to server. That's all. Still w3c validator shows this stupid "Start tag expected, '<' not found" :/Glandular
okay I've placed it on different server and it works now. Can server somehow influence it ?Glandular
Are you using flat html or a template/CMS? What server?Jevons
i'm using it as a django template but currently there are no django specific tags, only pure html.Glandular
O
7

Paste the below code within the head tag

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
Olshausen answered 11/1, 2013 at 9:5 Comment(0)
F
6

Quirks mode in any version of IE will also be triggered if anything precedes the DOCTYPE. For example, if a hypertext document contains a comment, space or any tag before the DOCTYPE declaration, IE will use quirks mode:

<!-- This comment will put IE 6, 7, 8, and 9 in quirks mode -->
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Fruitage answered 7/2, 2013 at 23:42 Comment(0)
D
3

I added both the doctype from the first comment and then the meta tag and it worked thanks guys .... and no thanks to IE :(

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

and

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

I have just changed the doctype to html5 and it still works great

 <!DOCTYPE html> 
    <html>
      <head> 
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
Dinorahdinosaur answered 4/2, 2013 at 14:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.