標籤提供關於HTML文檔的元數據。元數據不會顯示在頁面上,可是對於機器是可讀的。它可用於瀏覽器(如何顯示內容或從新加載頁面),搜索引擎(關鍵詞),或其餘 web 服務。web
Web網頁chrome
1.頁面關鍵詞,每一個網頁應具備描述該網頁內容的一組惟一的關鍵字。windows
<meta name="keywords" content="your tags" />
2.頁面描述,每一個網頁都應有一個不超過 150 個字符且能準確反映網頁內容的描述標籤。瀏覽器
<meta name="description" content="150 words" />
3.搜索引擎索引方式,robotterms是一組使用逗號(,)分割的值,一般有以下幾種取值:none,noindex,nofollow,all,index和follow。確保正確使用nofollow和noindex屬性值。緩存
<meta name="robots" content="index,follow" /> <!-- all:文件將被檢索,且頁面上的連接能夠被查詢; none:文件將不被檢索,且頁面上的連接不能夠被查詢; index:文件將被檢索; follow:頁面上的連接能夠被查詢; noindex:文件將不被檢索; nofollow:頁面上的連接不能夠被查詢。 -->
4.頁面重定向和刷新:content內的數字表明時間(秒),既多少時間後刷新。若是加url,則會重定向到指定網頁(搜索引擎可以自動檢測,也很容易被引擎視做誤導而受到懲罰)。app
<meta http-equiv="refresh" content="0;url=" />
5.其餘webapp
<meta name="author" content="author name" /> <!-- 定義網頁做者 --> <meta name="google" content="index,follow" /> <meta name="googlebot" content="index,follow" /> <meta name="verify" content="index,follow" />
移動設備iphone
1.viewport:能優化移動瀏覽器的顯示。若是不是響應式網站,不要使用initial-scale或者禁用縮放。大部分4.7-5寸設備的viewport寬設爲360px;5.5寸設備設爲400px;iphone6設爲375px;ipone6 plus設爲414px。ide
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/> <!-- `width=device-width` 會致使 iPhone 5 添加到主屏後以 WebApp 全屏模式打開頁面時出現黑邊 -->
width:寬度(數值 / device-width)(範圍從200 到10,000,默認爲980 像素) height:高度(數值 / device-height)(範圍從223 到10,000) initial-scale:初始的縮放比例 (範圍從>0 到10) minimum-scale:容許用戶縮放到的最小比例 maximum-scale:容許用戶縮放到的最大比例 user-scalable:用戶是否能夠手動縮 (no,yes) minimal-ui:能夠在頁面加載時最小化上下狀態欄。(已棄用)
2.WebApp全屏模式:假裝app,離線應用。字體
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- 啓用 WebApp 全屏模式 -->
3.隱藏狀態欄/設置狀態欄顏色:只有在開啓WebApp全屏模式時才生效。content的值爲default | black | black-translucent 。
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
4.添加到主屏後的標題
<meta name="apple-mobile-web-app-title" content="標題">
5.忽略數字自動識別爲電話號碼
<meta content="telephone=no" name="format-detection" />
6.忽略識別郵箱
<meta content="email=no" name="format-detection" />
7.添加智能 App 廣告條 Smart App Banner:告訴瀏覽器這個網站對應的app,並在頁面上顯示下載banner
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">
8.其餘
<!-- 針對手持設備優化,主要是針對一些老的不識別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">
1.申明編碼
<meta charset='utf-8' />
2.優先使用 IE 最新版本和 Chrome
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 關於X-UA-Compatible --> <meta http-equiv="X-UA-Compatible" content="IE=6" ><!-- 使用IE6 --> <meta http-equiv="X-UA-Compatible" content="IE=7" ><!-- 使用IE7 --> <meta http-equiv="X-UA-Compatible" content="IE=8" ><!-- 使用IE8 -->
3.瀏覽器內核控制:國內瀏覽器不少都是雙內核(webkit和Trident),webkit內核高速瀏覽,IE內核兼容網頁和舊版網站。而添加meta標籤的網站能夠控制瀏覽器選擇何種內核渲染。
<meta name="renderer" content="webkit|ie-comp|ie-stand">
4.禁止瀏覽器從本地計算機的緩存中訪問頁面內容:這樣設定,訪問者將沒法脫機瀏覽。
<meta http-equiv="Pragma" content="no-cache">
經常使用meta記憶
<!-- 字體編碼 --> <meta charset="utf-8" /> <!-- 關鍵字 --> <meta name="keywords" content="" /> <!-- 說明 --> <meta name="description" content="" /> <!-- 做者 --> <meta name="author" content="" /> <!-- 設置文檔寬度、是否縮放 --> <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no" /> <!-- 優先使用IE最新版本或chrome --> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 360讀取到這個標籤當即錢換到極速模式 --> <meta name="renderer" content="webkit" /> <!-- 禁止百度轉碼 --> <meta http-equiv="Cache-Control" content="no-siteapp" /> <!-- UC強制豎屏 --> <meta name="screen-orientation" content="portrait" /> <!-- QQ強制豎屏 --> <meta name="x5-orientation" content="portrait" /> <!-- UC強制全屏 --> <meta name="full-scerrn" content="yes" /> <!-- QQ強制全屏 --> <meta name="x5-fullscreen" content="ture" /> <!-- QQ應用模式 --> <meta name="x5-page-mode" content="app" /> <!-- UC應用模式 --> <meta name="browsermode" content="application"> <!-- window phone 點亮無高光 --> <meta name="msapplication-tap-highlight" content="no" /> <!-- 安卓設備不自動識別郵件地址 --> <meta name="format-detection" name="email=no" /> <!-- iOS設備 --> <!-- 添加到主屏幕的標題 --> <meta name="apple-mobile-web-app-title" content="標題" /> <!-- 是否啓用webApp全屏 --> <meta name="apple-mobile-web-app-capable" content="yes" /> <!-- 設置狀態欄的背景顏色,啓用webapp模式時生效 --> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent/black/default" /><!-- 半透明/黑色/默認白色 --> <!-- 禁止數字識別爲電話號碼 --> <meta name="format-detection" content="telephone=no" /> <!-- iOS圖標 iPhone/iTouch默認是57*57 iPad,72*72,能夠沒有,但推薦有 Retina iPhone/Retina iTouch,114*114,能夠沒有,但推薦有 Retina iPad,144*144,能夠沒有,但推薦有 iPhone 6 plus是180*180,iPhone 6 是120*120 --> <link rel="apple--touch-icon-precomposed" sizes="width*height" href="xxx.png" /> <!-- iOS啓動畫面 --> <!-- iPad啓動是不包含狀態欄的 --> <!-- 標準分辨率:一、豎屏(768*1004);二、橫屏(1024*748) Retina:一、豎屏(1536*2008);二、橫屏(2048*1496) --> <!-- iPhone/iTouch啓動是包含狀態欄的 --> <!-- 標準分辨率(320*480)、Retina(640*960)、iPhone 5/iTouch 5(640*1136) --> <link rel="apple-touch-startup-image" sizes="width*height" href="xxx.png" /> <!-- iPhone 6對應的圖片大小是750×1294,iPhone 6 Plus 對應的是1242×2148 --> <link rel="apple-touch-startup-image" href="xxx.png" media="(device-width:375px)"> <link rel="apple-touch-startup-image" href="xxx.png" media="(device-width:414px)"> <!-- 智能添加廣告條 --> <meta name="apple-itunes-app" content="app-id=myappstoreID,affiliate-data=myaffiliatedata,app-argument=myurl" />