天天看點

html頭部meta屬性大全——各種奇葩屬性設定大歸類

常用通用屬性:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

<!--設定螢幕縮放-->

<link rel="dns-prefetch" href="//www.zhoulujun.cn">

<!--設定dns緩存-->

<meta name="applicable-device" content="pc,mobile">

<!--設定支援終端-->

網頁相關資訊設定

<meta name="keywords" content="周陸軍“/>

<!--設定網頁關鍵詞,SEO-->

<meta name="description" content="周陸軍網站"/>

<!--設定網頁内容描述,SEO-->

<meta name="author" content="周陸軍"/>

<!--設定網頁作者-->

<meta name="generator"content="資訊參數"/>

<!--說明網站的采用的什麼軟體制作-->

<meta name='Copyright' content='zhoulujun'>

<!--說明網站版權資訊-->

<meta name="revisit-after" content="7days"'>

<!--revisit-after代表網站重訪,7days代表7天,依此類推。-->

http-equiv屬性

<meta http-equiv="expires"content="Fri,12Jan200118:18:18GMT">

<!--可以用于設定網頁的到期時間。一旦網頁過期,必須到伺服器上重新傳輸。-->

<meta http-equiv="Pragma"content="no-cache">

<!--禁止浏覽器從本地計算機的緩存中通路頁面内容。-->

<meta http-equiv="Refresh"content="2;URL=http://www.haorooms.com">

<!--自動重新整理并指向新頁面。其中的2是指停留2秒鐘後自動重新整理到URL網址。-->

<meta http-equiv="Set-Cookie"content="cookie value=xxx;expires=Friday,12-Jan-200118:18:18GMT;path=/">

<!--如果網頁過期,那麼存盤的cookie将被删除。注意:必須使用GMT的時間格式。-->

<meta http-equiv="content-Type"content="text/html;charset=gb2312">

<!--設定頁面使用的字元集。-->

<meta http-equiv="Content-Language"content="zh-cn"/>

<!--設定顯示語言-->

<Meta http-equiv="Content-Script-Type"Content="text/javascript">

<!--指明頁面中腳本的類型-->

IOS的頭部設定

<meta name="apple-mobile-web-app-title" content="标題">

<!-- 添加到主屏後的标題(iOS 6 新增) -->

<meta name="apple-mobile-web-app-capable" content="yes"/>

<!-- 是否啟用 WebApp 全屏模式,删除蘋果預設的工具欄和菜單欄 -->

<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">

<!-- 添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari) -->

<meta name="apple-mobile-web-app-status-bar-style" content="black"/>

<!-- 設定蘋果工具欄顔色 -->

iOS 圖示設定

<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png"/>

<!-- iPhone 和 iTouch,預設 57x57 像素,必須有 -->

<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png"/>

<!-- Retina iPhone 和 Retina iTouch,114x114 像素,可以沒有,但推薦有 -->

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png"/>

<!-- Retina iPad,144x144 像素,可以沒有,但推薦有 -->

iOS 啟動畫面

<link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png"/>

<!-- iPad 豎屏 768 x 1004(标準分辨率) -->

<link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png"/>

<!-- iPad 豎屏 1536x2008(Retina) -->

<link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png"/>

<!-- iPad 橫屏 1024x748(标準分辨率) -->

<link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png"/>

<!-- iPad 橫屏 2048x1496(Retina) -->

<link rel="apple-touch-startup-image" href="/splash-screen-320x480.png"/>

<!-- iPhone/iPod Touch 豎屏 320x480 (标準分辨率) -->

<link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png"/>

<!-- iPhone/iPod Touch 豎屏 640x960 (Retina) -->

<link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png"/>

<!-- iPhone 5/iPod Touch 5 豎屏 640x1136 (Retina) -->

一些特殊浏覽器的設定:

QQ浏覽器相關設定:

<meta name="x5-orientation" content="portrait">

<!-- QQ強制豎屏 -->

<meta name="x5-fullscreen" content="true">

<!-- QQ強制全屏 -->

<meta name="x5-page-mode" content="app">

<!-- QQ應用模式 -->

UC浏覽器相關設定:    

<!-- UC強制豎屏 -->

<meta name="screen-orientation" content="portrait">

<!-- UC強制全屏 -->

<meta name="full-screen" content="yes">

<!-- UC應用模式 -->

<meta name="browsermode" content="application">

360浏覽器:

<meta name="renderer" content="webkit">

<!-- 啟用360浏覽器的極速模式(webkit) -->

windows相關裝置:

<meta name="msapplication-tap-highlight" content="no">

<!-- windows phone 點選無高光 -->

<meta name="msapplication-TileColor" content="#000"/>

<!-- Windows 8 磁貼顔色 -->

<meta name="msapplication-TileImage" content="icon.png"/>

<!-- Windows 8 磁貼圖示 -->

<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml"/>

<!-- 添加 RSS 訂閱 -->

<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>

<!-- 添加 favicon icon -->

其他裝置設定:

<meta name="HandheldFriendly" content="true">

<!-- 針對手持裝置優化,主要是針對一些老的不識别viewport的浏覽器,比如黑莓 -->

最後講講常用的老浏覽器霸主IE

<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">

<!-- 避免IE使用相容模式 -->

X-UA-Compatible是神馬?

X-UA-Compatible是IE8的一個專有<meta>屬性,它告訴IE8采用何種IE版本去渲染網頁,在html的<head>标簽中使用。可以在微軟官方文檔擷取更多介紹。

為什麼要用X-UA-Compatible?

在IE8剛推出的時候,很多網頁由于重構的問題,無法适應較進階的浏覽器,是以使用X-UA-Compatible标簽強制IE8采用低版本方式渲染。

使用下面這段代碼後,開發者無需考慮網頁是否相容IE8浏覽器,隻要確定網頁在IE6、IE7下的表現就可以了。

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

使用下面這段代碼使用的是Edge 。模式Edge 模式告訴 IE 以最進階模式渲染文檔,也就是任何 IE 版本都以目前版本所支援的最進階标準模式渲染,避免版本更新造成的影響。簡單的說,就是什麼版本 IE        就用什麼版本的标準模式渲染。

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

使用以下代碼強制 IE 使用 Chrome Frame 渲染

<meta http-equiv="X-UA-Compatible" content="chrome=1">

最佳的相容模式方案:

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

ps:為防止失效,X-UA-Compatible最好緊跟在head之後,之前不要有任何不标準的标簽。

下面是配置大全

<link rel="dns-prefetch" href="//www.zhoulujun.cn">
<!--設定dns緩存-->
<meta name="applicable-device" content="pc,mobile">
<!--設定支援終端-->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<!--設定螢幕縮放-->
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
<!--設定頁面使用的字元集。-->
<meta http-equiv="Content-Language" content="zh-cn"/>
<!--設定顯示語言-->



<meta name="keywords" content="周陸軍"/>
<!--設定網頁關鍵詞,SEO-->
<meta name="description" content="周陸軍網站"/>
<!--設定網頁内容描述,SEO-->
<meta name="author" content="周陸軍"/>
<!--設定網頁作者-->
<meta name="generator" content="intellij"/>
<!--說明網站的采用的什麼軟體制作-->
<meta name='Copyright' content='zhoulujun'>
<!--說明網站版權資訊-->


<meta name="apple-mobile-web-app-title" content="周陸軍的個人網站">
<!-- 添加到主屏後的标題(iOS 6 新增) -->
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!-- 是否啟用 WebApp 全屏模式,删除蘋果預設的工具欄和菜單欄 -->
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=http://www.zhoulujun.cn">
<!-- 添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari) -->
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<!-- 設定蘋果工具欄顔色 -->


<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png"/>
<!-- iPhone 和 iTouch,預設 57x57 像素,必須有 -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png"/>
<!-- Retina iPhone 和 Retina iTouch,114x114 像素,可以沒有,但推薦有 -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png"/>
<!-- Retina iPad,144x144 像素,可以沒有,但推薦有 -->






<meta name="x5-orientation" content="portrait">
<!-- QQ強制豎屏 -->
<meta name="x5-fullscreen" content="true">
<!-- QQ強制全屏 -->
<meta name="x5-page-mode" content="app">
<!-- QQ應用模式 -->


<!-- UC強制豎屏 -->
<meta name="screen-orientation" content="portrait">
<!-- UC強制全屏 -->
<meta name="full-screen" content="yes">
<!-- UC應用模式 -->
<meta name="browsermode" content="application">

<meta name="renderer" content="webkit">
<!-- 啟用360浏覽器的極速模式(webkit) -->


<meta name="msapplication-tap-highlight" content="no">
<!-- windows phone 點選無高光 -->
<meta name="msapplication-TileColor" content="#000"/>
<!-- Windows 8 磁貼顔色 -->
<meta name="msapplication-TileImage" content="icon.png"/>
<!-- Windows 8 磁貼圖示 -->
<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml"/>
<!-- 添加 RSS 訂閱 -->
<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>
<!-- 添加 favicon icon -->


<meta name="HandheldFriendly" content="true">
<!-- 針對手持裝置優化,主要是針對一些老的不識别viewport的浏覽器,比如黑莓 -->      

參考文章:    http://www.bubblypoker.com/2016/11/07/h5%E5%A4%B4%E9%83%A8meta%E6%95%B4%E7%90%86/

http://www.cnblogs.com/nidilzhang/archive/2010/01/09/1642887.html