What does <meta http-equiv=“X-UA-Compatible” content=“IE=edge”> do?

后端 未结 12 1417
情书的邮戳
情书的邮戳 2020-11-21 06:11

What\'s the difference if one web page starts with

 
 
   
    

        
相关标签:
12条回答
  • 2020-11-21 07:00

    Since I can not add a comment to the marked answer I will just post this here.

    In addition to the correct answer you can indeed have this validated. Since this meta tag is only directed for IE all you need to do is add a IE conditional.

    <!--[if IE]>
        <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <![endif]-->
    

    Doing this is just like adding any other IE conditional statement and only works for IE and no other browsers will be affected.

    0 讨论(0)
  • 2020-11-21 07:00

    if you use your website in the same network as the server IE likes to switch to compability mode despite DOCTYPE.
    Adding meta http-equiv="X-UA-Compatible" content="IE=Edge" disables this unwanted behaviour.

    0 讨论(0)
  • 2020-11-21 07:00

    2.1.3.5 X-UA-Compatibility Meta Tag and HTTP Response Header

    This functionality will not be implemented in any version of Microsoft Edge.

    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />
    

    See https://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx

    Yes, I know that I'm late to the party, but I just had some issues and discussions, and in the end my boss had me remove the X-UA-Compatible tag remove from all documents I've been working on.

    If this information is out-of-date or no longer relevant, please correct me.

    0 讨论(0)
  • 2020-11-21 07:04
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    

    To make this line work as expected, make sure that:

    1. It is the first element right after <head>
    2. No conditional comments are used before the meta tag, e. g. on the <html> element

    Otherwise some IE versions simply ignore it.

    UPDATE

    These two rules are simplified but they are easy to remember and to verify. Despite MSDN docs stating you can put title and other meta tags before this one, I would not recommend to do so.

    How make it work with conditional comments.

    Interesting article about the order of elements in the head. (blogs.msdn.com, for IE)

    REFERENCE

    From the MSDN documentation:

    The X-UA-Compatible [...] must appear in the header of the webpage (the HEAD section) before all other elements except for the title element and other meta elements.

    0 讨论(0)
  • 2020-11-21 07:06

    I think this diagram from Microsoft explains all. In order to tell IE how to render the content, !DOCTYPE has to work with X-UA-Compatible meta tag. !DOCTYPE by itself has no affect on changing IE Document Mode.

    http://ie.microsoft.com/testdrive/ieblog/2010/Mar/02_HowIE8DeterminesDocumentMode_3.png

    0 讨论(0)
  • 2020-11-21 07:07

    Just for completeness, you don't actually have to add it to your HTML (which is unknown http-equiv in HTML5)

    Do this and never look back (first example for apache, second for nginx)

    Header set X-UA-Compatible "IE=Edge,chrome=1"
    
    add_header X-UA-Compatible "IE=Edge,chrome=1";
    
    0 讨论(0)
提交回复
热议问题