X-UA-Compatible 是專為 IE 設計的文檔模式控制標籤,不影響 Chrome/Firefox/Edge 等現代瀏覽器。其核心作用是強制指定 IE 使用特定版本的渲染引擎。
<!DOCTYPE html> 僅觸發標準模式,但 IE 有多個版本的標準模式(IE7 Standards, IE8 Standards, IE9 Standards...)| 值 | 渲染模式 | 適用場景 |
|---|---|---|
IE=edge | 使用當前 IE 最高版本標準模式 | 現代網站,追求最佳標準支持 |
IE=11 | 強制 IE11 標準模式 | 需鎖定 IE11 行為 |
IE=10 | 強制 IE10 標準模式 | 兼容 IE10 特定特性 |
IE=9 | 強制 IE9 標準模式 | 兼容 IE9 特定特性 |
IE=8 | 強制 IE8 標準模式 | 老系統兼容 |
IE=7 | 強制 IE7 標準模式 | 極老系統兼容 |
IE=5 | 強制 Quirks 模式 (IE5.5 渲染) | 極度古老內聯網應用 |
EmulateIE7 | 模擬 IE7:有 Doctype 用 IE7 Standards,無 Doctype 用 Quirks | 遷移期兼容,尊重 Doctype |
EmulateIE8 | 模擬 IE8:有 Doctype 用 IE8 Standards,無則 Quirks | 同理 |
IE=7:無視 Doctype,強制 IE7 Standards 模式EmulateIE7:尊重 Doctype,有 Doctype 則 IE7 Standards,無則 QuirksIE=8 vs EmulateIE8<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 兼容舊項目可用:content="IE=8; IE=9; IE=10; IE=edge" -->
<title>頁面標題</title>
</head>
<head> 開頭,優先於除 <title> 外所有標籤IE=edge 是現代項目首選,確保用戶獲得最佳渲染X-UA-Compatible: IE=edge(Nginx/Apache/IIS 可全局配置)詳細對比:X-UA-Compatible 詳細解析