Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
來看下常用的標(biāo)簽列表,后文會一一介紹:
<!DOCTYPE html> <!-- 使用 HTML5 doctype,不區(qū)分大小寫 -->
<html lang="zh-cmn-Hans"> <!-- 更加標(biāo)準(zhǔn)的 lang 屬性寫法 http://zhi.hu/XyIa -->
<head>
<meta charset='utf-8'> <!-- 聲明文檔使用的字符編碼 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 優(yōu)先使用 IE 最新版本和 Chrome -->
<meta name="description" content="不超過150個(gè)字符" /> <!-- 頁面描述 -->
<meta name="keywords" content=""/> <!-- 頁面關(guān)鍵詞 -->
<meta name="author" content="name, email@gmail.com" /> <!-- 網(wǎng)頁作者 -->
<meta name="robots" content="index,follow" /> <!-- 搜索引擎抓取 -->
<!-- 為移動設(shè)備添加 viewport -->
<meta name ="viewport" content ="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no"> <!-- `width=device-width` 會導(dǎo)致 iPhone 5 添加到主屏后以 WebApp 全屏模式打開頁面時(shí)出現(xiàn)黑邊 http://bigc.at/ios-webapp-viewport-meta.orz -->
<!-- iOS 設(shè)備 begin -->
<meta name="apple-mobile-web-app-title" content="標(biāo)題"> <!-- 添加到主屏后的標(biāo)題(iOS 6 新增) -->
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- 是否啟用 WebApp 全屏模式 -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <!-- 設(shè)置狀態(tài)欄的背景顏色,只有在 `"apple-mobile-web-app-capable" content="yes"` 時(shí)生效 -->
<meta name="format-detection" content="telephone=no" /> <!-- 禁止數(shù)字識自動別為電話號碼 -->
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> <!-- 添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari) -->
<!-- iOS 圖標(biāo) begin -->
<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png" /> <!-- iPhone 和 iTouch,默認(rèn) 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 圖標(biāo) end -->
<!-- iOS 啟動畫面 begin -->
<link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png" /> <!-- iPad 豎屏 768 x 1004(標(biāo)準(zhǔn)分辨率) -->
<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(標(biāo)準(zhǔn)分辨率) -->
<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 (標(biāo)準(zhǔn)分辨率) -->
<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) -->
<!-- iOS 啟動畫面 end -->
<!-- iOS 設(shè)備 end -->
<meta name="msapplication-TileColor" content="#000"/> <!-- Windows 8 磁貼顏色 -->
<meta name="msapplication-TileImage" content="icon.png"/> <!-- Windows 8 磁貼圖標(biāo) -->
<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 -->
<title>標(biāo)題</title>
</head>
基本標(biāo)簽
使用 HTML5 doctype,不區(qū)分大小寫。
<!DOCTYPE html> <!-- 使用 HTML5 doctype,不區(qū)分大小寫 -->
聲明文檔使用的字符編碼
<meta charset='utf-8'> <!-- 聲明文檔使用的字符編碼 -->
更加標(biāo)準(zhǔn)的 lang 屬性寫法 http://zhi.hu/XyIa
很少情況才需要加地區(qū)代碼,通常是為了強(qiáng)調(diào)不同地區(qū)漢語使用差異,例如:
<p lang="zh-cmn-Hans">
<strong lang="zh-cmn-Hans-CN">菠蘿</strong>和<strong lang="zh-cmn-Hant-TW">鳳梨</strong>其實(shí)是同一種水果。只是大陸和臺灣稱謂不同,且新加坡、馬來西亞一帶的稱謂也是不同的,稱之為<strong lang="zh-cmn-Hans-SG">黃梨</strong>。
</p>
優(yōu)先使用 IE 最新版本和 Chrome
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 優(yōu)先使用 IE 最新版本和 Chrome -->
SEO 優(yōu)化
頁面描述
每個(gè)網(wǎng)頁都應(yīng)有一個(gè)不超過 150 個(gè)字符且能準(zhǔn)確反映網(wǎng)頁內(nèi)容的描述標(biāo)簽。文檔
<meta name="description" content="不超過150個(gè)字符" /> <!-- 頁面描述 -->
頁面關(guān)鍵詞
<meta name="keywords" content=""/> <!-- 頁面關(guān)鍵詞 -->
定義頁面標(biāo)題
<title>標(biāo)題</title>
定義網(wǎng)頁作者
<meta name="author" content="name, email@gmail.com" /> <!-- 網(wǎng)頁作者 -->
定義網(wǎng)頁搜索引擎索引方式,robotterms是一組使用英文逗號「,」分割的值,通常有如下幾種取值:none,noindex,nofollow,all,index和follow。文檔
<meta name="robots" content="index,follow" /> <!-- 搜索引擎抓取 -->
可選標(biāo)簽
為移動設(shè)備添加 viewport
<meta name ="viewport" content ="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no"> <!-- `width=device-width` 會導(dǎo)致 iPhone 5 添加到主屏后以 WebApp 全屏模式打開頁面時(shí)出現(xiàn)黑邊 http://bigc.at/ios-webapp-viewport-meta.orz -->
content 參數(shù):
iOS 設(shè)備
添加到主屏后的標(biāo)題(iOS 6 新增)
<meta name="apple-mobile-web-app-title" content="標(biāo)題"> <!-- 添加到主屏后的標(biāo)題(iOS 6 新增) -->
是否啟用 WebApp 全屏模式
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- 是否啟用 WebApp 全屏模式 -->
設(shè)置狀態(tài)欄的背景顏色
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <!-- 設(shè)置狀態(tài)欄的背景顏色,只有在 `"apple-mobile-web-app-capable" content="yes"` 時(shí)生效 -->
content 參數(shù):
如果設(shè)置為 default 或 black ,網(wǎng)頁內(nèi)容從狀態(tài)欄底部開始。
如果設(shè)置為 black-translucent ,網(wǎng)頁內(nèi)容充滿整個(gè)屏幕,頂部會被狀態(tài)欄遮擋。
禁止數(shù)字識自動別為電話號碼
<meta name="format-detection" content="telephone=no" /> <!-- 禁止數(shù)字識自動別為電話號碼 -->
iOS 圖標(biāo)
rel 參數(shù):
apple-touch-icon 圖片自動處理成圓角和高光等效果。
apple-touch-icon-precomposed 禁止系統(tǒng)自動添加效果,直接顯示設(shè)計(jì)原圖。
iPhone 和 iTouch,默認(rèn) 57x57 像素,必須有
<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png" /> <!-- iPhone 和 iTouch,默認(rèn) 57x57 像素,必須有 -->
iPad,72x72 像素,可以沒有,但推薦有
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/apple-touch-icon-72x72-precomposed.png" /> <!-- iPad,72x72 像素,可以沒有,但推薦有 -->
Retina iPhone 和 Retina iTouch,114x114 像素,可以沒有,但推薦有
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png" /> <!-- Retina iPhone 和 Retina iTouch,114x114 像素,可以沒有,但推薦有 -->
Retina iPad,144x144 像素,可以沒有,但推薦有
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png" /> <!-- Retina iPad,144x144 像素,可以沒有,但推薦有 -->
iOS 啟動畫面
官方文檔:https://developer.apple.com/library/ios/qa/qa1686/_index.html
參考文章:http://wxd.ctrip.com/blog/2013/09/ios7-hig-24/
iPad 的啟動畫面是不包括狀態(tài)欄區(qū)域的。
iPad 豎屏 768 x 1004(標(biāo)準(zhǔn)分辨率)
<link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png" /> <!-- iPad 豎屏 768 x 1004(標(biāo)準(zhǔn)分辨率) -->
iPad 豎屏 1536x2008(Retina)
<link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png" /> <!-- iPad 豎屏 1536x2008(Retina) -->
iPad 橫屏 1024x748(標(biāo)準(zhǔn)分辨率)
<link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png" /> <!-- iPad 橫屏 1024x748(標(biāo)準(zhǔn)分辨率) -->
iPad 橫屏 2048x1496(Retina)
<link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png" /> <!-- iPad 橫屏 2048x1496(Retina) -->
iPhone 和 iPod touch 的啟動畫面是包含狀態(tài)欄區(qū)域的。
iPhone/iPod Touch 豎屏 320x480 (標(biāo)準(zhǔn)分辨率)
<link rel="apple-touch-startup-image" href="/splash-screen-320x480.png" /> <!-- iPhone/iPod Touch 豎屏 320x480 (標(biāo)準(zhǔn)分辨率) -->
iPhone/iPod Touch 豎屏 640x960 (Retina)
<link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png" /> <!-- iPhone/iPod Touch 豎屏 640x960 (Retina) -->
iPhone 5/iPod Touch 5 豎屏 640x1136 (Retina)
<link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png" /> <!-- iPhone 5/iPod Touch 5 豎屏 640x1136 (Retina) -->
添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari)文檔
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> <!-- 添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari) -->
Android
Android Lollipop 中的 Chrome 39 增加 theme-color meta 標(biāo)簽,用來控制選項(xiàng)卡顏色。
http://updates.html5rocks.com/2014/11/Support-for-theme-color-in-Chrome-39-for-Android
<meta name="theme-color" content="#db5945">
Windows 8
Windows 8 磁貼顏色
<meta name="msapplication-TileColor" content="#000"/> <!-- Windows 8 磁貼顏色 -->
Windows 8 磁貼圖標(biāo)
<meta name="msapplication-TileImage" content="icon.png"/> <!-- Windows 8 磁貼圖標(biāo) -->
其他
添加 RSS 訂閱
<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml" /> <!-- 添加 RSS 訂閱 -->
添加 favicon icon
<link rel="shortcut icon" type="image/ico" href="/favicon.ico" /> <!-- 添加 favicon icon -->
禁止 Chrome 瀏覽器中自動提示翻譯
、定義
<meta> 標(biāo)簽提供關(guān)于 HTML 文檔的元數(shù)據(jù)。它不會顯示在頁面上,但是對于機(jī)器是可讀的。可用于瀏覽器(如何顯示內(nèi)容或重新加載頁面),搜索引擎(關(guān)鍵詞),或其他 web 服務(wù)。
2、作用
meta里的數(shù)據(jù)是供機(jī)器解讀的,告訴機(jī)器該如何解析這個(gè)頁面,還有一個(gè)用途是可以添加服務(wù)器發(fā)送到瀏覽器的http頭部內(nèi)容,例如我們?yōu)轫撁嬷刑砑尤缦耺eta標(biāo)簽:
瀏覽器的頭部就會包括這些:
只有瀏覽器可以接受這些附加的頭部字段,并能以適當(dāng)?shù)姆绞绞褂盟鼈儠r(shí),這些字段才有意義。
3、meta的必需屬性和可選屬性
meta的必需屬性是content,當(dāng)然并不是說meta標(biāo)簽里一定要有content,而是當(dāng)有http-equiv或name屬性的時(shí)候,一定要有content屬性對其進(jìn)行說明。例如:
必需屬性
<meta name="keywords" content="HTML,ASP,PHP,SQL">
這里面content里的屬性就是對keywords進(jìn)行的說明,所以呢也可以理解成一個(gè)鍵值對吧,就是{keywords:"HTML,ASP,PHP,SQL"}。
可選屬性
在W3school中,對于meta的可選屬性說到了三個(gè),分別是http-equiv、name和scheme。考慮到scheme不是很常用,所以就只說下前兩個(gè)屬性吧。
http-equiv
http-equiv屬性是添加http頭部內(nèi)容,對一些自定義的,或者需要額外添加的http頭部內(nèi)容,需要發(fā)送到瀏覽器中,我們就可以是使用這個(gè)屬性。在上面的meta作用中也有簡單的說明,那么現(xiàn)在再舉個(gè)例子。例如我們不想使用js來重定向,用http頭部內(nèi)容控制,那么就可以這樣控制:
<meta http-equiv="Refresh" content="5;url=http://blog.yangchen123h.cn" />
在頁面中加入這個(gè)后,5秒鐘后就會跳轉(zhuǎn)到指定頁面啦,效果可看W3school的例子
name
第二個(gè)可選屬性是name,這個(gè)屬性是供瀏覽器進(jìn)行解析,對于一些瀏覽器兼容性問題,name屬性是最常用的,當(dāng)然有個(gè)前提就是瀏覽器能夠解析你寫進(jìn)去的name屬性才可以,不然就是沒有意義的。還是舉個(gè)例子吧:
<meta name="renderer" content="webkit">
這個(gè)meta標(biāo)簽的意思就是告訴瀏覽器,用webkit內(nèi)核進(jìn)行解析,當(dāng)然前提是瀏覽器有webkit內(nèi)核才可以,不然就是沒有意義的啦。當(dāng)然看到這個(gè)你可能會有疑問,這個(gè)renderer是從哪里冒出來的,我要怎么知道呢?這個(gè)就是在對應(yīng)的瀏覽器的開發(fā)文檔里就會有表明的,例如這個(gè)renderer是在360瀏覽器里說明的。360瀏覽器內(nèi)核控制Meta標(biāo)簽說明文檔
常用meta標(biāo)簽大總結(jié)
接下來就是常用的meta標(biāo)簽大總結(jié)啦,我會盡可能的做到全
charset
charset是聲明文檔使用的字符編碼,解決亂碼問題主要用的就是它,值得一提的是,這個(gè)charset一定要寫第一行,不然就可能會產(chǎn)生亂碼了。
charset有兩種寫法
兩個(gè)都是等效的。
百度禁止轉(zhuǎn)碼
百度會自動對網(wǎng)頁進(jìn)行轉(zhuǎn)碼,這個(gè)標(biāo)簽是禁止百度的自動轉(zhuǎn)碼
<meta http-equiv="Cache-Control" content="no-siteapp" />
SEO 優(yōu)化部分
viewport
viewport主要是影響移動端頁面布局的,例如:
content 參數(shù):
各瀏覽器平臺
Microsoft Internet Explorer
Google Chrome
360瀏覽器
UC手機(jī)瀏覽器
UCBrowser_U3_API
QQ手機(jī)瀏覽器
Apple iOS
Google Android
App Links
最后——移動端常用的meta
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" name="keywords" content="HTML,前端,css">
<title></title>
</head>
<body>
</body>
</html>
meta主要設(shè)置網(wǎng)頁中的一些元數(shù)據(jù),元數(shù)據(jù)不是給用戶看的
charset: 指定網(wǎng)頁的字符集
name: 指定的數(shù)據(jù)的名稱
content: 指定的數(shù)據(jù)的內(nèi)容
1 - 定義文檔關(guān)鍵詞,用于搜索引擎:
<meta name="keywords" content="HTML, CSS, XML, XHTML, JavaScript">
2 - 定義web頁面描述: <meta name="description" content="">
3 - 定義頁面作者:
<meta name="author" content="Tigger">
4 - 每10秒刷新頁面:
<meta http-equiv="refresh" content="10">
5 - 頁面重定向:
<meta http-equiv="refresh" content="10;url=https://www.baidu.com">
meta標(biāo)簽屬性.png
`
*請認(rèn)真填寫需求信息,我們會在24小時(shí)內(nèi)與您取得聯(lián)系。