---
title: "【转载】HTML5 声明兼容IE的写法"
author: "zhoon"
date: "2012-05-08T17:22:57Z"
tags: ["HTML5", "兼容IE"]
categories: ["Web前端"]
slug: "html5-ie"
draft: false
lastmod: "2012-05-08T17:23:17Z"
id: 1517576
url: "https://zhoon.iteye.com/blog/1517576"
---

```
<!DOCTYPE html>
<!–[if IE]>
<meta http-equiv=”X-UA-Compatible” content=”IE=8″ />
<![endif]–>
<!–[if IE 7]>
<meta http-equiv=”X-UA-Compatible” content=”IE=7″ />
<![endif]–>
<!–[if IE 6]>
<meta http-equiv=”X-UA-Compatible” content=”IE=6″ />
<![endif]–>
```

 

# 关于X-UA-Compatible

目前绝大多数网站都用

`<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >`

来作为IE8的兼容方法，虽然微软将IE向标准迈进了一大步，而事实上IE8还存在一系列渲染的奇怪现象是不争的事实。  
谁让IE6那么多呢，或许2014年以后我们可以有更多的时间去关心IE8，而不是IE6或者IE7。  
在X-UA-Compatible中可用的方法有：  
`<meta http-equiv="X-UA-Compatible" content="IE=5" >`

`<meta http-equiv="X-UA-Compatible" content="IE=7" >`

`<meta http-equiv="X-UA-Compatible" content="IE=8" >`

`<meta http-equiv="X-UA-Compatible" content="IE=edge" >`

其中最后一行是永远以最新的IE版本模式来显示网页的。

另外加上

`<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >`

`<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" >`

而使用，Emulate模式后则更重视&lt;!DOCTYPE&gt;

所以目前来说还是以

`<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >`

为首选。

微软自己创下的罪孽让他自己去扫吧。

 

转自：http://www.mhtml5.com/2012/05/4901.html