佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > HTML5中meta屬性的使用方法

HTML5中meta屬性的使用方法

熱門標(biāo)簽:網(wǎng)站建設(shè) 使用U盤裝系統(tǒng) 檢查注冊表項 阿里云 美圖手機 智能手機 百度競價點擊價格的計算公式 硅谷的囚徒呼叫中心

meta屬性在HTML中占據(jù)了很重要的位置。如:針對搜索引擎的SEO,文檔的字符編碼,設(shè)置刷新緩存等。雖然一些網(wǎng)頁可能沒有使用meta,但是作為正規(guī)軍,我們還是有必要了解一些meta的屬性,并且能夠熟練使用它們。

1、聲明文檔使用的字符編碼

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <meta charset='utf-8'>  
  2.   

2、聲明文檔的兼容模式

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 指示IE以目前可用的最高模式顯示內(nèi)容   
  2. <meta http-equiv="X-UA-Compatible" content="IE=Emulate IE7" />指示IE使用 <!DOCTYPE> 指令確定如何呈現(xiàn)內(nèi)容。標(biāo)準(zhǔn)模式指令以IE7 標(biāo)準(zhǔn)模式顯示,而 Quirks 模式指令以 IE5 模式顯示。   
  3.   

3、SEO 優(yōu)化

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <meta name="description" content="不超過150個字符" />頁面描述   
  2. <meta name="keywords" content="html5, css3, 關(guān)鍵字"/>頁面關(guān)鍵詞   
  3. <meta name="author" content="魔法小棧" />定義網(wǎng)頁作者   
  4. <meta name="robots" content="index,follow" />定義網(wǎng)頁搜索引擎索引方式,robotterms是一組使用英文逗號「,」分割的值,通常有如下幾種取值:none,noindex,nofollow,all,index和follow。   
  5.   

4、為移動設(shè)備添加 viewport

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <meta name ="viewport" content ="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">  
  2.     content 參數(shù)解釋:   
  3.     width       viewport 寬度(數(shù)值/device-width)   
  4.     height            viewport 高度(數(shù)值/device-height)   
  5.     initial-scale  初始縮放比例   
  6.     maximum-scale  最大縮放比例   
  7.     minimum-scale  最小縮放比例   
  8.     user-scalable  是否允許用戶縮放(yes/no)   
  9.     minimal-ui      iOS 7.1 beta 2 中新增屬性,可以在頁面加載時最小化上下狀態(tài)欄。這是一個布爾值,可以直接這樣寫:   
  10. <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">  
  11.   

5、iOS 設(shè)備

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <meta name="apple-mobile-web-app-title" content="標(biāo)題">添加到主屏后的標(biāo)題(iOS 6 新增)   
  2. <meta name="apple-mobile-web-app-capable" content="yes" />是否啟用 WebApp 全屏模式   
  3. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />設(shè)置狀態(tài)欄的背景顏色   
  4.     只有在 "apple-mobile-web-app-capable" content="yes" 時生效   
  5.     content 參數(shù):   
  6.     default 默認值。   
  7.     black 狀態(tài)欄背景是黑色。   
  8.     black-translucent 狀態(tài)欄背景是黑色半透明。   
  9.     設(shè)置為 default 或 black ,網(wǎng)頁內(nèi)容從狀態(tài)欄底部開始。   
  10.     設(shè)置為 black-translucent ,網(wǎng)頁內(nèi)容充滿整個屏幕,頂部會被狀態(tài)欄遮擋。   
  11.   

6、iOS 圖標(biāo) rel 參數(shù)

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. apple-touch-icon 圖片自動處理成圓角和高光等效果。   
  2. apple-touch-icon-precomposed 禁止系統(tǒng)自動添加效果,直接顯示設(shè)計原圖。   
  3. <link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png" />iPhone 和 iTouch,默認 57x57 像素,必須有   
  4. <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/apple-touch-icon-72x72-precomposed.png" />iPad,72x72 像素,可以沒有,但推薦有   
  5. <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png" />Retina iPhone 和 Retina iTouch,114x114 像素,可以沒有,但推薦有   
  6. <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png" />Retina iPad,144x144 像素,可以沒有,推薦大家使用   
  7. <meta name="apple-mobile-web-app-title" content="標(biāo)題">title最好限制在六個中文長度內(nèi),超長的內(nèi)容會被隱藏,添加到主屏后的標(biāo)題(iOS 6 新增)   
  8.   

7、iOS 啟動畫面

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. iPad 的啟動畫面是不包括狀態(tài)欄區(qū)域的。   
  2. iPad 豎屏 768 x 1004(標(biāo)準(zhǔn)分辨率)   
  3. <link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png" />iPad 豎屏 1536x2008(Retina)   
  4. <link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png" />iPad 橫屏 1024x748(標(biāo)準(zhǔn)分辨率)   
  5. <link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png" />iPad 橫屏 2048x1496(Retina)   
  6. <link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png" />  
  7. iPhone 和 iPod touch 的啟動畫面是包含狀態(tài)欄區(qū)域的。   
  8. iPhone/iPod Touch 豎屏 320x480 (標(biāo)準(zhǔn)分辨率)   
  9. <link rel="apple-touch-startup-image" href="/splash-screen-320x480.png" />iPhone/iPod Touch 豎屏 640x960 (Retina)   
  10. <link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png" />iPhone 5/iPod Touch 5 豎屏 640x1136 (Retina)   
  11. <link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png" />  
  12. <link rel="apple-touch-startup-image" href="Startup.png" />  當(dāng)用戶點擊主屏圖標(biāo)打開 WebApp 時,系統(tǒng)會展示啟動畫面,在未設(shè)置情況下系統(tǒng)會默認顯示該網(wǎng)站的首頁截圖,當(dāng)然這個體驗不是很好   
  13.   

8、Windows 8

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <meta name="msapplication-TileColor" content="#000"/> Windows 8 磁貼顏色   
  2. <meta name="msapplication-TileImage" content="icon.png"/>Windows 8 磁貼圖標(biāo)   
  3.   

9、不常用的

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml" />添加 RSS 訂閱   
  2. <link rel="shortcut icon" type="image/ico" href="/favicon.ico" />添加 favicon icon   
  3. <meta name="format-detection" content="telephone=no" />禁止數(shù)字識自動別為電話號碼   
  4. <meta name="format-detection" content="email=no" />不讓android識別郵箱   
  5. <meta name="renderer" content="webkit">啟用360瀏覽器的極速模式(webkit)   
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">避免IE使用兼容模式   
  7. <meta name="HandheldFriendly" content="true">針對手持設(shè)備優(yōu)化,主要是針對一些老的不識別viewport的瀏覽器,比如黑莓   
  8. <meta name="MobileOptimized" content="320">微軟的老式瀏覽器   
  9. <meta name="x5-orientation" content="portrait">QQ強制豎屏   
  10. <meta name="full-screen" content="yes">UC強制全屏   
  11. <meta name="x5-fullscreen" content="true">QQ強制全屏   
  12. <meta name="browsermode" content="application">UC應(yīng)用模式   
  13. <meta name="x5-page-mode" content="app">QQ應(yīng)用模式   
  14. <meta http-equiv="Cache-Control" content="no-siteapp" />禁止百度轉(zhuǎn)碼   
  15. <meta name="msapplication-tap-highlight" content="no">windows phone 點擊無高光   
  16. <meta name="keywords" content="" />  關(guān)鍵字   
  17. <meta name="description" content="" />  描述   
  18. <meta name="title" content="" />  標(biāo)題   
  19. <meta name="author" content="-06" />  作者   
  20. <meta name="Copyright" content="" />  公司   
  21. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">   讓IE瀏覽器用最高級內(nèi)核渲染頁面 還有用 Chrome 框架的頁面用webkit 內(nèi)核    
  22. <meta name="apple-mobile-web-app-capable" content="yes">  IOS6全屏   
  23. <meta name="mobile-web-app-capable" content="yes">  Chrome高版本全屏   
  24. <meta name="renderer" content="webkit">  讓360雙核瀏覽器用webkit內(nèi)核渲染頁面   
  25. <meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> 添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari)   
  26.   

10、sns 社交標(biāo)簽

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <meta property="og:type" content="類型" />  
  2. <meta property="og:url" content="URL地址" />  
  3. <meta property="og:title" content="標(biāo)題" />  
  4. <meta property="og:image" content="圖片" />  
  5. <meta property="og:description" content="描述" />  
  6.   

11、條件注釋判斷IE瀏覽器

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <!--[if IE]>條件注釋區(qū)分非IE瀏覽器   
  2. <!--[if lt IE 7 ]><html class="oldie ie ie6"> <![endif]-->     
  3. <!--[if IE 7 ]><html class="oldie ie ie7"> <![endif]-->     
  4. <!--[if IE 8 ]><html class="ie ie8"> <![endif]-->     
  5. <!--[if (gte IE 9)|!(IE)]><!--><html> <!--<![endif]-->    
  6.   

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。
<!--[if lt IE 9]>  <![endif]-->

標(biāo)簽:湘潭 煙臺 通遼 黃山 懷化 山南 賀州 湖北

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《HTML5中meta屬性的使用方法》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    弋阳县| 县级市| 巴林左旗| 襄垣县| 辽阳县| 天津市| 岳阳县| 兰西县| 广元市| 张家川| 宜宾市| 邓州市| 彭水| 彩票| 宝清县| 安远县| 邻水| 桓仁| 杭锦旗| 和林格尔县| 洱源县| 韩城市| 阿合奇县| 马边| 屏山县| 咸宁市| 宁河县| 平利县| 绥宁县| 西藏| 永安市| 广南县| 运城市| 嘉祥县| 隆德县| 东宁县| 陈巴尔虎旗| 湘乡市| 潼南县| 隆回县| 丹江口市|