基本介绍
- meta 标签主要是用来描述一个 html 网页文档的属性的,例如作者、日期、时间、页面刷新
- 用于 seo 的搜索优化
设置浏览器不缓存
1 2 3 4
| <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0">
|
name 属性
meta是用来在HTML文档中模拟HTTP协议的响应头报文。meta 标签用于网页的 <head></head> 中,meta 标签的用处很多。meta 的属性有两种:name和http-equiv。name属性主要用于描述网页,对应于content(网页内容),以便于搜索引擎机器人查找、分类(目前几乎所有的搜索引擎都使用网上机器人自动查找meta值来给网页分类)。这其中最重要的是description(站点在搜索引擎上的描述)和keywords(分类关键词),所以应该给每页加一个meta值。比较常用的有以下几个:
1 2 3 4 5 6 7 8 9 10 11 12
| <meta charset="utf-8">
<meta name="keywords" content="关于meta标签,网页"> <meta name="description" content="HTML中<meta>标签如何正确使用">
<meta name="author" content="author-name">
<meta name="robot" content="none">
|
robot 属性有 all、none、index、noindex、follow 和 nofollow。默认为 all。
- 设定为all:文件将被检索,且页面上的链接可以被查询;
- 设定为none:文件将不被检索,且页面上的链接不可以被查询;
- 设定为index:文件将被检索;
- 设定为follow:页面上的链接可以被查询;
- 设定为noindex:文件将不被检索,但页面上的链接可以被查询;
- 设定为nofollow:文件将不被检索,页面上的链接可以被查询。
http-equiv
1 2 3 4 5 6 7 8 9 10 11 12
| <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="expires" content="Wed, 02 Jan 2019 07:31:31 GMT">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="refresh" content="1; url=https://www.baidu.com"/>
|
其他常用设置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <meta name="applicable-device" content="pc,mobile" />
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta content="telephone=no,email=no" name="format-detection" />
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="yes" name="apple-touch-fullscreen" />
<meta name="full-screen" content="yes">
<meta name="x5-fullscreen" content="true">
<meta http-equiv="Cache-Control" content="no-transform" /> <meta http-equiv="Cache-Control" content="no-siteapp" />
|
条件注释
- html5shiv让浏览器可以识别html5的新标签
- respond让低版本浏览器可以使用CSS3的媒体查询