Which X-UA-Compatible mode should I be using?

后端 未结 3 1064
逝去的感伤
逝去的感伤 2021-01-18 00:49

I have been reading around the subject of using document compatibility meta tag to web pages.



        
相关标签:
3条回答
  • 2021-01-18 01:20

    If you are talking about creating new web pages for use on the public Internet, my advice would be to use an HTML5 doctype or other strict doctype and no X-UA-Compatible meta tag. This would be equivalent to one with IE=edge, by the way. This is for web pages compatible with all versions of IE.

    You can add the X-UA-Compatible meta tag to an existing page that is only compatible with IEn and lower if you don't have the time or inclination to update it to support the latest version(s) of IE right now. In that case you can use IE=n, where n is the latest version of IE that the page works on. IE versions later than n will go into "IEn mode" and render the page as IEn did. Note that n cannot be less than 7, as that is the first version to support this system. There is no real point to using IE=EmulateIEn on an actual page, that is only useful for when you are sending a blanket header to an entire site via http, instead of altering individual pages. In that case, EmulateIEn would go into "IEn mode" only if a strict doctype was on the page, and into "quirks mode" otherwise.

    0 讨论(0)
  • 2021-01-18 01:24

    What Rob said. Supporting various IEs has nothing to do with compat mode. The X-UA-Compatible header simply makes the IE the site is viewed on to use the latest, most modern layout engine that it has if you set content="IE=edge" IE9 has all IE 8, IE 7, IE 6, and quirks mode supported. IE10 will be supporting IE9 and below as respective engines to render on. So, if you set content="IE=6" it means that particular IE is supposed to use IE 6 engine to render the site - which completely defeats the purpose of using a modern browser.

    In HTML5 Boilerplate, we also add chrome=1 so if Chrome Frame is installed, that site will take advantage of that and render the site like it is rendering on Chrome.

    0 讨论(0)
  • 2021-01-18 01:33
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  
    

    is the one you want to use but, so early this morning, I can't recall the reasoning, but it's the one we use everywhere.

    With all the various forms of this and combinations of versions of IE, I believe there are something in the hundreds of varieties of coding for IE. Ain't life grand?

    0 讨论(0)
提交回复
热议问题