<meta>標籤
提供了HTML文檔的元數據。元數據不會顯示在客戶端,但是會被瀏覽器解析。
一個標籤內可以使用如下幾個屬性:charset、name、content、http-equiv
。
【注意】:HTML5中scheme屬性已被棄用。
name屬性
該屬性的可取值如下:
- keywords :用於告訴搜索引擎,你網頁的關鍵字,關鍵字以逗號分隔。
<meta name="keywords" content="HTML5,前端,代碼,樣式" />
- description :用於告訴搜索引擎,你網站的主要內容。
<meta name="description" content="該網站是一個專注於大學生教育的免費平臺。" />
- viewport :用於設計移動端網頁。
<meta name="viewport" content="width=device-width, initial-scale=1" />
更多請參考:viewport深入理解
- robots :robots用來告訴爬蟲哪些頁面需要索引,哪些頁面不需要索引。可取值有:
none : 搜索引擎將忽略此網頁,等價於noindex,nofollow。
noindex : 搜索引擎不索引此網頁。
nofollow: 搜索引擎不繼續通過此網頁的鏈接索引搜索其它的網頁。
all : 搜索引擎將索引此網頁與繼續通過此網頁的鏈接索引,等價於index,follow。
index : 搜索引擎索引此網頁。
follow : 搜索引擎繼續通過此網頁的鏈接索引搜索其它的網頁。
<meta name="robots" content="all" />
- author :用於標註網頁作者。
<meta name="author" content="Jane" />
- format-detection :主要對移動端網頁一些鏈接進行檢測識別。可取值有:
#1 將數字顯示爲撥號鏈接:
<meta name="format-detection" content="telephone=no" />
telephone = no 禁止把數字轉爲撥號鏈接;
telephone = yes 開啓數字轉撥號鏈接,默認是開啓的,可以不用寫。
#2 對郵箱的自動識別:
<meta name="format-detection" content="email=no" />
email = no 禁止作爲郵箱地址。
email = yes 看做郵箱地址,默認下開啓。
#3 跳轉地圖:
<<meta name="format-detection" content="adress=no" />
adress=no禁止跳轉至地圖!
adress=yes就開啓了點擊地址直接跳轉至地圖的功能,在默認是情況下就是開啓!
<meta name="format-detection" content="telephone=no,email=no,adress=no" />
- generator :用來設置網站採用什麼軟件製作的。
<meta name="generator" content="hobbit" />
- COPYRIGHT :用來設置網站的版權信息。
<meta name="COPYRIGHT" content="your site" />
http-equiv 屬性
- expires :用來設置網頁的過期時間。
<meta http-equiv="expires" content="Fri May 13 2016 22:49:44 GMT+0800 (CST)" />
- Pragma :用來設置禁止瀏覽器從本地緩存中訪問頁面。
<meta http-equiv="Pragma" content="no-cache" />
- Refresh :用來設置自動刷新並跳轉新頁面。
<meta http-equiv="Refresh" content="5;URL=http://m.baichanghui.com" />
- Set-Cookie :用來設置 Cookie。
<meta http-equiv="Set-Cookie" content="cookie value=xxx;expires=Friday,12-Jan-200118:18:18GMT;path=/" />
- Window-target :強制頁面在當前窗口以獨立頁面顯示。
<meta http-equiv="Window-target" content="top" />
- content-Type:設置頁面使用的字符集。
<meta http-equiv="content-Type" content="text/html;charset=gb2312" />
- Content-Language :設置頁面的語言。
<meta http-equiv="Content-Language" content="zh-cn" />
- Cache-Control :設置頁面緩存。
<meta http-equiv="Cache-Control" content="no-cache" />
- Content-Script-Type :設置頁面中腳本的類型。
<meta http-equiv="Content-Script-Type" content="text/javascript" />
- page_enter、page_exit :設定進入頁面和離開頁面時的特殊效果。
#進入頁面
<meta http-equiv="Page-Enter" contect="revealTrans(duration=1.0,transtion= 12)" />
#離開頁面
<meta http-equiv="Page-Exit" contect="revealTrans(duration=1.0,transtion= 12)" />
Duration的值爲網頁動態過渡的時間,單位爲秒。
Transition是過渡方式,它的值爲0到23,分別對應24種過渡方式。如下:
0 盒狀收縮 1 盒狀放射
2 圓形收縮 3 圓形放射
4 由下往上 5 由上往下
6 從左至右 7 從右至左
8 垂直百葉窗 9 水平百葉窗
10 水平格狀百葉窗 11 垂直格狀百葉窗
12 隨意溶解 13 從左右兩端向中間展開
14 從中間向左右兩端展開 15 從上下兩端向中間展開
16 從中間向上下兩端展開 17 從右上角向左下角展開
18 從右下角向左上角展開 19 從左上角向右下角展開
20 從左下角向右上角展開 21 水平線狀展開
22 垂直線狀展開 23 隨機產生一種過渡方式
參考:
https://www.jianshu.com/p/6549bec5d0e1
https://blog.csdn.net/weixin_43207025/article/details/94323249