1. 程式人生 > >html頭部meta屬性大全——各種奇葩屬性設置大歸類

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

前端開發 html標簽設置

常用通用屬性:

<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=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/

cnblogs.com/nidilzhang/

cnblogs.com/chendc/p/54

轉載請註明文章出處:html頭部meta屬性大全--各種奇葩屬性設置大歸類 - html5 - 周陸軍的個人網站


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