Html5 meta標籤用法總結

meta元素共有三個可選屬性(http-equiv、name和scheme)和一個必選屬性(content),content定義與 http-equiv 或 name 屬性相關的元信息。
可選屬性

屬性 描述
http-equiv content-type / expire / refresh / set-cookie 把content屬性關聯到HTTP頭部
name author / description / keywords / generator / revised / others 把 content 屬性關聯到一個名稱
scheme some_text 定義用於翻譯 content 屬性值的格式

必選屬性

屬性 描述
content some_text 定義與 http-equiv 或 name 屬性相關的元信息

name屬性

<!-- 頁面作者 -->
<meta name="author" content="7ge"/>
<!-- 頁面描述 -->
<meta name="description" content="這裏添加對頁面的描述"/>
<!-- 頁面關鍵詞 -->
<meta name="keywords" content="meta標籤總結,meta標籤,7ge"/>
<!-- 頁面生成器 -->
<meta name="generator" content="hexo" />
<!-- 頁面修改信息 -->
<meta name="revised" content="story,2015/07/22" />
<!-- 版權信息 -->
<meta name="copyright" content="All Rights Reserved" />
<!-- 頁面爬蟲設置 -->
<meta name="robots" content="index,follow" />
<!-- robots的content取值 -->
<!-- all:文件將被檢索,且頁面上的鏈接可以被查詢 -->
<!-- none:文件將不被檢索,且頁面上的鏈接不可以被查詢 -->
<!-- index:文件將被檢索 -->
<!-- follow:頁面上的鏈接可以被查詢 -->
<!-- noindex:文件將不被檢索,但頁面上的鏈接可以被查詢 -->
<!-- nofollow:文件將被檢索,但頁面上的鏈接不可以被查詢 -->

http-equiv

<!-- 字符編碼 -->
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>html5中可以改寫成:<meta charset="utf-8"/>  
<!-- 頁面到期時間 -->
<meta http-equiv="expire" content="Wed,22Jul201511:11:11GMT" />
<!-- 頁面重刷新,0秒後刷新並跳轉 -->
<meta http-equiv="refresh" content="0;URL=''" />
<!-- cookie設置 -->
<meta http-equiv="set-cookie" content="cookiename value=xxx;expires=Wed,22-Jul-201511:11:11GMT;path=/" />
<!-- 腳本類型 -->
<meta http-equiv="Content-Script-Type"Content="text/javascript"/>
<!-- 禁止從本地緩存中讀取頁面 -->
<meta http-equiv="Pragma"content="no-cache"/> 

移動端

<!-- viewport的content取值 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
<!-- width:寬度(數值 / device-width)(200~10000,默認爲980px) -->
<!-- height:高度(數值 / device-height)(223~10000) -->
<!-- initial-scale:初始縮放比例 (0~10) -->
<!-- minimum-scale:允許用戶縮放到的最小比例 -->
<!-- maximum-scale:允許用戶縮放到的最大比例 -->
<!-- user-scalable:是否允許用戶縮放 (no/yes)  -->

<!-- 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"/>

<!-- IOS啓用 WebApp 全屏模式 -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- IOS全屏模式下隱藏狀態欄/設置狀態欄顏色 content的值爲default | black | black-translucent  -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<!-- IOS添加到主屏後的標題 -->
<meta name="apple-mobile-web-app-title" content="標題"/>
!-- IOS添加智能 App 廣告條 Smart App Banner -->
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">

<!-- 去除iphone 識別數字爲號碼 -->
<meta name="format-detection" content="telephone=no">
<!-- 不識別郵箱 -->
<meta name="format-detection" content="email=no">
<!-- 禁止跳轉至地圖 -->
<meta name="format-detection" content="adress=no">
<!-- 可以連寫-->
<meta name="format-detection" content="telephone=no,email=no,adress=no">

謝謝各位讀者補充!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章