Meta標籤是HTML語言head區的一個輔助性標籤,它位於HTML文檔頭部的head標記和title標記之間,它提供用戶不可見的信息。Meta : 即 元數據(Metadata)是數據的數據信息。html
元數據能夠被使用瀏覽器(如何顯示內容或從新加載頁面),搜索引擎(關鍵詞),或其餘 Web 服務調用。前端
用咱們的大白話來講,它自己是一個沒什麼用的標籤,可是一旦在它內部經過其餘屬性設置了某些效果,它就起做用了,因此咱們稱之爲「 元數據 」。ios
<!-- 定義文檔的字符編碼 --> <meta charset="utf-8" /> <!-- 強制Chromium內核,做用於360瀏覽器、QQ瀏覽器等國產雙核瀏覽器 --> <meta name="renderer" content="webkit"/> <!-- 強制Chromium內核,做用於其餘雙核瀏覽器 --> <meta name="force-rendering" content="webkit"/> <!-- 若是有安裝 Google Chrome Frame 插件則強制爲Chromium內核,不然強制本機支持的最高版本IE內核,做用於IE瀏覽器 --> <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/> <!-- 設置視窗大小 width 設置layout viewport 的寬度,爲一個正整數,或字符串"width-device" initial-scale 設置頁面的初始縮放值,爲一個數字,能夠帶小數 minimum-scale 容許用戶的最小縮放值,爲一個數字,能夠帶小數 maximum-scale 容許用戶的最大縮放值,爲一個數字,能夠帶小數 shrink-to-fit=no IOS9中要想前面的屬性起做用須要加上這個 height 設置layout viewport 的高度,這個屬性對咱們並不重要,不多使用 user-scalable 是否容許用戶進行縮放,值爲"no"或"yes", no 表明不容許,yes表明容許 --> <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/> <!-- 頁面描述 --> <meta name="description" content="不超過150個字符"/> <!-- 頁面關鍵詞 --> <meta name="keywords" content=""/> <!-- 網頁做者 --> <meta name="author" content="name, email@gmail.com"/> <!-- 搜索引擎抓取 all:文件將被檢索,且頁面上的連接能夠被查詢; none:文件將不被檢索,且頁面上的連接不能夠被查詢; index:文件將被檢索; follow:頁面上的連接能夠被查詢; noindex:文件將不被檢索; nofollow:頁面上的連接不能夠被查詢。 --> <meta name="robots" content="index,follow"/> <!-- 忽略頁面中的數字識別爲電話,忽略email識別--> <meta name="format-detection" content="telphone=no, email=no"/> <!-- IOS begin --> <!-- 添加到主屏後的標題(iOS 6 新增) --> <meta name="apple-mobile-web-app-title" content="標題"> <!-- 當網站添加到主屏幕快速啓動方式,可隱藏地址欄,僅針對ios的safari (ios7.0版本之後,safari上已看不到效果) --> <meta name="apple-mobile-web-app-capable" content="yes"/> <!-- 是否啓用 WebApp 全屏模式,刪除蘋果默認的工具欄和菜單欄 --> <meta name="apple-touch-fullscreen" content="yes"/> <!-- 添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari) --> <meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> <!-- 設置蘋果工具欄顏色:默認值爲 default(白色),能夠定爲 black(黑色)和 black-translucent(灰色半透明) --> <meta name="apple-mobile-web-app-status-bar-style" content="black"/> <!-- 不讓百度轉碼 --> <meta http-equiv="Cache-Control" content="no-siteapp" /> <!-- 針對手持設備優化,主要是針對一些老的不識別viewport的瀏覽器,好比黑莓 --> <meta name="HandheldFriendly" content="true"> <!-- 微軟的老式瀏覽器 --> <meta name="MobileOptimized" content="320"> <!-- uc強制豎屏 --> <meta name="screen-orientation" content="portrait"> <!-- QQ強制豎屏 --> <meta name="x5-orientation" content="portrait"> <!-- UC強制全屏 --> <meta name="full-screen" content="yes"> <!-- QQ強制全屏 --> <meta name="x5-fullscreen" content="true"> <!-- UC應用模式 --> <meta name="browsermode" content="application"> <!-- QQ應用模式 --> <meta name="x5-page-mode" content="app"> <!-- windows phone 點擊無高光 --> <meta name="msapplication-tap-highlight" content="no"> <!-- iOS 圖標 begin 網站添加至ios桌面時的圖標 --> <!-- iPhone 和 iTouch,默認 57x57 像素,必須有 --> <link rel="apple-touch-icon-precomposed" sizes="57x57" href="table_ico57.png"> <!-- Retina iPhone 和 Retina iTouch,114x114 像素,能夠沒有,但推薦有 --> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="table_ico72.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="table_ico114.png"> <!-- Retina iPad,144x144 像素,能夠沒有,但推薦有 --> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="table_ico144.png"> <!-- iOS 啓動畫面 begin --> <!-- iPad 豎屏 768 x 1004(標準分辨率) --> <link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png"/> <!-- iPad 橫屏 1024x748(標準分辨率) --> <link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png"/> <!-- iPad 豎屏 1536x2008(Retina) --> <link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png"/> <!-- iPad 橫屏 2048x1496(Retina) --> <link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png"/> <!-- iPhone/iPod Touch 豎屏 320x480 (標準分辨率) --> <link rel="apple-touch-startup-image" href="/splash-screen-320x480.png"/> <!-- iPhone/iPod Touch 豎屏 640x960 (Retina) --> <link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png"/> <!-- iPhone 5/iPod Touch 5 豎屏 640x1136 (Retina) --> <link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png"/> <!-- IOS end --> <!-- Windows 8 磁貼顏色 --> <meta name="msapplication-TileColor" content="#000"/> <!-- Windows 8 磁貼圖標 --> <meta name="msapplication-TileImage" content="icon.png"/> <!-- 添加 RSS 訂閱 --> <link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml"/> <!-- sns 社交標籤 begin --> <!-- 參考微博API --> <meta property="og:type" content="類型" /> <meta property="og:url" content="URL地址" /> <meta property="og:title" content="標題" /> <meta property="og:image" content="圖片" /> <meta property="og:description" content="描述" /> <!-- sns 社交標籤 end -->
添加好強制Webkit內核的代碼,使用國產瀏覽器訪問網站已經不存在IE兼容問題了,IE訪客量將大大減小。但仍然不可避免會有一些老舊電腦經過低版本IE瀏覽器訪問,若是咱們專門爲了這極小部分用戶進行 CSS HACK ,將嚴重加劇咱們的工做量。web
更況且自2016年1月起微軟已經中止爲IE11如下版本提供支持和更新,已經這麼久沒有更新,低版本IE不只對CSS3和HTML5支持有問題,更有安全問題。chrome
那麼,咱們不去支持低版本IE,這小部分用戶怎麼辦呢?windows
咱們可使用 if IE 語句給網站添加IE升級提示,提示用戶進行瀏覽器升級,或者切換更先進的瀏覽器再訪問。瀏覽器
咱們能夠在剛剛的meta標籤下添加一段跳轉到IE升級提示頁的代碼(當IE版本低於IE11時跳轉),實現低版本IE用戶訪問時提示他們進行升級或者更換瀏覽器。安全
強制Webkit內核和提示低版本IE訪問用戶升級完整代碼以下所示,把這段代碼添加到頭部模板文件<head>標籤下便可:服務器
<meta name="renderer" content="webkit"/> <meta name="force-rendering" content="webkit"/> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> <script>/*@cc_on window.location.href="http://support.dmeng.net/upgrade-your-browser.html?referrer="+encodeURIComponent(window.location.href); @*/</script>(@cc_on 是 IE10 及更舊版IE特有的條件編譯語句,所以能夠用來判斷是否除 IE11 之外的其餘IE版本。)app
由於低版本IE訪問時由於不兼容CSS3和HTML5網站每每是錯版的,添加了上面這段代碼,當低版本IE用戶訪問時就會跳轉到升級提示頁,避免沒必要要的資源加載,下降網站服務器開銷。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <meta name="renderer" content="webkit"/> <meta name="force-rendering" content="webkit"/> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> <script>/*@cc_on window.location.href="http://support.dmeng.net/upgrade-your-browser.html?referrer="+encodeURIComponent(window.location.href); @*/</script> </head> <body> <h1>Hello world</h1> </body> </html>
參考
經過meta代碼強制瀏覽器使用WebKit內核極速模式(解決 meta name="renderer" content="webkit" 不起做用)- [艾歡歡](https://blog.csdn.net/AiHuanh...