<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