meta介绍
meta提供关于html文档的元数据。元数据不会显示在页面上,但是对于机器是可读的。它可用于浏览器(如何显示内容或者重新加载页面),搜索引擎(关键词),或其他web服务。
申明编码
<meta charset="utf-8" />
优先使用IE最新版和Chrome
<meta http-quiv="X-UA-Compatible" content="IE=edge,chrome=1" />
浏览器内核控制
国内浏览器很多都是双内核(webkit和Trident),webkit内核高速浏览,IE内核兼容网页和旧版网站。
国内双核浏览器内核模式为:
- 搜狗高速浏览器、QQ浏览器:IE内核(兼容模式)
- 360极速浏览器、搜狗浏览器:Webkit内核(极速模式)
而添加meta标签的网站可以控制浏览器选择何种内核渲染。
<meta name="renderer" content="webkit|ie-comp|ie-stand" />
页面关键字(important)
关键词最好控制在12个以内,非越多越好。
<meta name="keywords" content="your tags, ..." />
页面描述(important)
描述字数控制在120~150之间,标点符号也包括在内。
<meta name="description" content="120| 150 words" />
搜索引擎索引方式
<meta name="robots" content="index,follow" />
all: 文件将被检索,且页面上的链接可以被查询
none: 文件将不被检索,且页面上的链接不可以被查询
index: 文件将被检索
follow: 页面上的链接可以被查询
noindex: 文件将不被检索
nofollow: 页面上的链接不可以被查询
页面重定向和刷新
<meta http-equiv="refresh" content="0;url=" />
content内的数字代表时间(秒),即多少时间后刷新;假如加url,则会重定向到指定网页
搜索引擎能够自动检测,很容易被引擎视作误导而受到惩罚
网页作者信息
<meta name="author" content="author name" />
针对移动设备
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
WebApp全屏模式
伪装app,离线应用
<meta name="apple-mobile-web-app-capable" content="yes" />
隐藏状态栏/设置状态栏颜色
只有在开启WebApp全屏模式时才生效
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
content的值为default|black|black-translucent
添加到主屏后的标题
<meta name="apple-mobile-web-app-title" content="标题" />
content的值为default|black|black-translucent
忽略数字自动识别为电话号码
<meta content="telephone=no" name="format-detection" />
当为yes时,电话号码显示为拨号的超链接(默认情况下即为打开,当为这个时就没有必要写)
忽略识别邮箱
<meta content="email=no" name="format-detection" />
当为yes时,把文字默认为邮箱地址(默认情况下即为打开,当为这个时就没有必要写)