Is it legal to use IE specific metatags in HTML5?

2019-04-22 21:27发布

问题:

Ive been trying to validate an html5 document with the following 2 lines in the header:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="imagetoolbar" content="no" />

The entire document validates very nicely, but these 2 lines, which are IE specific, render the page invalid.

My question: is there a legal HTML5 syntax for these metatags? i'd very much like my code to be valid, but these tags cannot be dispensed with.

回答1:

Depending on your access to the server/server-side code, you could deliver X-UA-Compatible as a header. I am not sure if the same can be done for imagetoolbar.

Edit: Your other option would be conditional comments:

<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="imagetoolbar" content="no" />
<![endif]-->