??meta 標簽大全

引用地址1
引用地址2
保存下來,以便查閱

什么是meta標簽?

  • 元數據(metadata),是關于數據的信息
  • 標簽提供關于 HTML 文檔的元數據。元數據不會顯示在頁面上,但是對于機器是可讀的。
  • 典型的情況是,meta 元素被用于規定頁面的描述、關鍵詞、文檔的作者、最后修改時間以及其他元數據。
  • 標簽始終位于 head 元素中。
  • 元數據可用于瀏覽器(如何顯示內容或重新加載頁面),搜索引擎(關鍵詞),或其他 web 服務。

屬性名區域:

content 屬性 必選屬性
始終要和 name 屬性或 http-equiv 屬性一起使用。即而是當有http-equiv或name屬性的時候,一定要有content屬性對其進行說明。

<!-- 示例見keywords -->

name 屬性 可選屬性
這個屬性是供瀏覽器進行解析,對于一些瀏覽器兼容性問題,name屬性是最常用的,當然有個前提就是瀏覽器能夠解析你寫進去的name屬性才可以,不然就是沒有意義的。

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

http-equiv 屬性 可選屬性
指示服務器在發送實際的文檔之前先在要傳送給瀏覽器的 MIME 文檔頭部包含名稱/值對。當服務器向瀏覽器發送文檔時,會先發送許多名稱/值對。雖然有些服務器會發送許多這種名稱/值對,但是所有服務器都至少要發送一個:content-type:text/html。這將告訴瀏覽器準備接受一個 HTML 文檔。使用帶有 http-equiv 屬性的 <meta> 標簽時,服務器將把名稱/值對添加到發送給瀏覽器的內容頭部

<meta http-equiv="charset" content="iso-8859-1">
<meta http-equiv="expires" content="31 Dec 2008">
<!--  
發送到瀏覽器的頭部就會包含
content-type: text/html
charset:iso-8859-1
expires:31 Dec 2008
 -->

scheme 屬性 可選屬性
用于指定要用來翻譯屬性值的方案。此方案應該在由 <head> 標簽的 profile 屬性指定的概況文件中進行了定義。
charset
charset是聲明文檔使用的字符編碼,解決亂碼問題主要用的就是它,值得一提的是,這個charset一定要寫第一行,不然就可能會產生亂碼了。

<!--  charset有兩種寫法 -->
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

屬性值區域:

keywords,description(常用的兩個)

<meta name="keywords" content="HTML,CSS,JAVASCRIPT,PHP">
<meta name="description" content="html meta標簽大全,整理一下加強記憶">

Content-Type
告訴瀏覽器當前訪問的資源類型

<!--告訴瀏覽器當前訪問的資源類型 并聲明編碼-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

refresh
重定向(以下示例,5秒后會跳轉到:http://blog.csdn.net

<meta http-equiv="refresh" content="5;url=http://blog.csdn.net" />

full-screen
全屏顯示網頁(部分移動端瀏覽器的專有屬性)

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

browsermode
瀏覽器模式-強制豎屏顯示(部分移動端瀏覽器的專有屬性)

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

format-detection
數據格式驗證渲染:
telephone:而iPhone會自動把你這個文字加鏈接樣式、并且點擊這個數字還會自動撥號!默認開啟
email:瀏覽器會識別郵箱并增加樣式,點擊調用系統默認郵件應用并給改地址發郵件!默認開啟
address:address=yes就開啟了點擊地址直接跳轉至地圖的功能,默認開啟


x5-orientation
QQ瀏覽器強制豎屏

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

x5-fullscreen
QQ瀏覽器強制全屏

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

x5-page-mode
QQ瀏覽器應用模式

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

X-UA-Compatible
IE的兼容模式:以IE的哪個版本去渲染頁面(IE=8:以IE8的模式去渲染頁面,IE=Edge:以最新版本的IE去渲染頁面,當然這個最新指的是你系統裝的最高版本的IE)

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

renderer
這貌似是360瀏覽器專用,兼容360的利器啊,,360默認是用IE7去渲染頁面的,不管你的系統裝了多高版本的IE,這種行為真是業界毒瘤啊。

<meta name="renderer" content="webkit">//默認webkit內核
<meta name="renderer" content="ie-comp">//默認IE兼容模式
<meta name="renderer" content="ie-stand">//默認IE標準模式

常用寫法:

設置頁面不緩存

<!-- 禁止瀏覽器從本地計算機的緩存中訪問頁面內容 -->
<meta http-equiv=”pragma” content=”no-cache”>
<!-- 禁止瀏覽器緩存 -->
<meta http-equiv=”cache-control” content=”no-cache”>
<!--
 網頁的緩存過期時間 
 比如<meta HTTP-EQUIV="expires" CONTENT="60">表示網頁在60秒后過期
 <meta HTTP-EQUIV="expires" CONTENT="-1">這是特殊的用法,表示網頁在任何時候都不能被Cache存儲
-->
<meta http-equiv=”expires” content=”0″>

<!--頁面重定向和刷新 -->
<meta http-equiv="refresh" content="0;url=" />

百度禁止轉碼

<!--  百度會自動對網頁進行轉碼,這個標簽是禁止百度的自動轉碼 -->

<meta http-equiv="Cache-Control" content="no-siteapp" />

SEO 優化部分

<!-- 頁面關鍵詞 keywords -->
<meta name="keywords" content="your keywords">
<!-- 頁面描述內容 description -->
<meta name="description" content="your description">
<!-- 定義網頁作者 author -->
<meta name="author" content="author,email address">
<!--
    定義網頁搜索引擎索引方式,robotterms 是一組使用英文逗號「,」分割的值
    通常有如下幾種取值
  all:文件將被檢索,且頁面上的鏈接可以被查詢;
  none:文件將不被檢索,且頁面上的鏈接不可以被查詢;
  index:文件將被檢索;
  follow:頁面上的鏈接可以被查詢;
  noindex:文件將不被檢索;
  nofollow:頁面上的鏈接不可以被查詢。
  -->
<meta name="robots" content="index,follow">

viewport

<!--  viewport主要是影響移動端頁面布局的,例如: -->

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--
    content 參數: 
    width: viewport 寬度(數值/device-width)
    height: viewport 高度(數值/device-height)
    initial-scale: 初始縮放比例
    maximum-scale: 最大縮放比例
    minimum-scale: 最小縮放比例
    user-scalable: 是否允許用戶縮放(yes/no)
 -->

各瀏覽器平臺:

IE

<!-- 優先使用最新的ie版本 -->
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-- 是否開啟cleartype顯示效果 -->
<meta http-equiv="cleartype" content="on">
<meta name="skype_toolbar" content="skype_toolbar_parser_compatible">


<!-- Pinned Site -->
<!-- IE 10 / Windows 8 -->
<meta name="msapplication-TileImage" content="pinned-tile-144.png">
<meta name="msapplication-TileColor" content="#009900">
<!-- IE 11 / Windows 9.1 -->
<meta name="msapplication-config" content="ieconfig.xml">

Chrome

<!-- 優先使用最新的chrome版本 -->
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<!-- 禁止自動翻譯 -->
<meta name="google" value="notranslate">

360

<!-- 選擇使用的瀏覽器解析內核 -->
<meta name="renderer" content="webkit|ie-comp|ie-stand">

UC手機瀏覽器

<!-- 將屏幕鎖定在特定的方向 -->
<meta name="screen-orientation" content="landscape/portrait">
<!-- 全屏顯示頁面 -->
<meta name="full-screen" content="yes">
<!-- 強制圖片顯示,即使是"text mode" -->
<meta name="imagemode" content="force">
<!-- 應用模式,默認將全屏,禁止長按菜單,禁止手勢,標準排版,強制圖片顯示。 -->
<meta name="browsermode" content="application">
<!-- 禁止夜間模式顯示 -->
<meta name="nightmode" content="disable">
<!-- 使用適屏模式顯示 -->
<meta name="layoutmode" content="fitscreen">
<!-- 當頁面有太多文字時禁止縮放 -->
<meta name="wap-font-scale" content="no">

QQ手機瀏覽器

<!-- 鎖定屏幕在特定方向 -->
<meta name="x5-orientation" content="landscape/portrait">
<!-- 全屏顯示 -->
<meta name="x5-fullscreen" content="true">
<!-- 頁面將以應用模式顯示 -->
<meta name="x5-page-mode" content="app">

Apple iOS

<!-- Smart App Banner -->
<meta name="apple-itunes-app" content="app-id=APP_ID,affiliate-data=AFFILIATE_ID,
app-argument=SOME_TEXT">


<!-- 禁止自動探測并格式化手機號碼 -->
<meta name="format-detection" content="telephone=no">
<!-- 忽略識別郵箱 -->
<meta content="email=no" name="format-detection" />

<!-- Add to Home Screen添加到主屏 -->
<!-- 是否啟用 WebApp 全屏模式 -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- 設置狀態欄的背景顏色,只有在 “apple-mobile-web-app-capable” content=”yes” 時生效 -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!-- 添加到主屏后的標題 -->
<meta name="apple-mobile-web-app-title" content="App Title">

Google Android

<meta name="theme-color" content="#E64545">
<!-- 添加到主屏 -->
<meta name="mobile-web-app-capable" content="yes">

App Links

<!-- iOS -->
<meta property="al:ios:url" content="applinks://docs">
<meta property="al:ios:app_store_id" content="12345">
<meta property="al:ios:app_name" content="App Links">
<!-- Android -->
<meta property="al:android:url" content="applinks://docs">
<meta property="al:android:app_name" content="App Links">
<meta property="al:android:package" content="org.applinks">
<!-- Web Fallback -->
<meta property="al:web:url" content="http://applinks.org/documentation">
<!-- More info: http://applinks.org/documentation/ -->

移動端

<!-- `width=device-width` 會導致 iPhone 5 添加到主屏后以 WebApp 全屏模式打開頁面時出現黑邊  -->
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection"content="telephone=no, email=no" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<!-- 刪除蘋果默認的工具欄和菜單欄 -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- 設置蘋果工具欄顏色 -->
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<!-- 忽略頁面中的數字識別為電話,忽略email識別 -->
<meta name="format-detection" content="telphone=no, email=no" />
<!-- 啟用360瀏覽器的極速模式(webkit) -->
<meta name="renderer" content="webkit">
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 針對手持設備優化,主要是針對一些老的不識別viewport的瀏覽器,比如黑莓 -->
<meta name="HandheldFriendly" content="true">
<!-- 微軟的老式瀏覽器 -->
<meta name="MobileOptimized" content="320">
<!-- 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">
<!-- windows phone 點擊無高光 -->
<meta name="msapplication-tap-highlight" content="no">
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容