Bad value X-UA-Compatible for attribute http-equiv on element meta

后端 未结 8 750
日久生厌
日久生厌 2020-11-30 23:31

I have used the same meta that HTML5 Boilerplate is using, and the W3C HTML validator complains:

Bad value X-UA-Compatible for attribute

相关标签:
8条回答
  • Either X-UA-Compatible is not "standard" HTML (FSVO "standard" that involves appearing on a publicly editable wiki page referenced by the specification) or the Validator isn't up to date with the current status of that wiki.

    At the time of writing (20130326) X-UA-Compatible appears on the wiki page under a section that states: "The following proposed extensions do not yet conform to all the registration requirements in the HTML spec and are therefore not yet allowed in valid documents." So the validator is correct to reject this value.

    0 讨论(0)
  • 2020-12-01 00:13

    If you're looking to make it technically valid (everyone loves to see the green favicon) w/o effecting any functionality, you should be able to just wrap it in a "if IE" tag.

    <!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
    
    0 讨论(0)
  • 2020-12-01 00:14

    Please remove ,chrome=1 from meta tag it will working fine. With validator:

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    
    0 讨论(0)
  • 2020-12-01 00:15

    .. may this be a good answer?

    Set HTTP Header with PHP:

    • http://www.joshuawinn.com/fix-html5-validator-error-bad-value-x-ua-compatible-for-attribute-http-equiv-on-element-meta/

    This is not my own work but I hope it is useful to others too.

    0 讨论(0)
  • 2020-12-01 00:17

    If you download/build the validator src code, you can add support yourself.

    Add the following to a file such as html5-meta-X-UA-Compatible.rnc) Then include it in html5full.rnc.

    I did this and it works nicely for validating.

    meta.http-equiv.X-UA-Compatible.elem =
      element meta { meta.inner & meta.http-equiv.X-UA-Compatible.attrs }
      meta.http-equiv.X-UA-Compatible.attrs =
        ( common.attrs.basic
          & common.attrs.i18n
          & common.attrs.present
          & common.attrs.other
          & meta.http-equiv.attrs.http-equiv.X-UA-Compatible
          & meta.http-equiv.attrs.content.X-UA-Compatible
          & ( common.attrs.aria.role.presentation
            | common.attrs.aria.role.menuitem
            )?
        )
        meta.http-equiv.attrs.http-equiv.X-UA-Compatible = attribute http-equiv {
          xsd:string {
            pattern = "X-UA-Compatible"
          }
        }
        meta.http-equiv.attrs.content.X-UA-Compatible = attribute content {
          xsd:string {
            pattern = "IE=((edge)|(EmulateIE(7|8|9|10))|7|8|9|10|11)(,chrome=(1|0))?"
          }
        }
    
    common.elem.metadata |= meta.http-equiv.X-UA-Compatible.elem
    
    0 讨论(0)
  • 2020-12-01 00:26

    I had the same issue and adding and to surround that entire line remedied the situation.

    <!--[if IE]><meta http-equiv="x-ua-compatible" content="IE=9" /><![endif]-->
    
    0 讨论(0)
提交回复
热议问题