meta标签基础知识

H5页面窗口自动调整到设备宽度,并禁止用户缩放页面

1
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />

忽略将页面中的数字识别为电话号码

1
<meta name="format-detection" content="telephone=no" />

忽略Android平台中对邮箱地址的识别

1
<meta name="format-detection" content="email=no" />

当网站添加到主屏幕快速启动方式,可隐藏地址栏,仅针对ios的safari

1
2
3
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- 删除苹果默认的工具栏和菜单栏 -->
<!-- ios7.0版本以后,safari上已看不到效果 -->

将网站添加到主屏幕快速启动方式,仅针对ios的safari顶端状态条的样式

1
2
3
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<!-- 设置苹果工具栏颜色 -->
<!-- 可选default、black、black-translucent -->

移动端的meta

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<meta name="format-detection" content="telphone=no, email=no" /><!-- 忽略页面中的数字识别为电话,忽略email识别 -->
<!-- 启用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">
<!-- 适应移动端end -->

SEO 优化部分

1
2
3
4
5
6
7
8
9
10
<!--页面标题<title>标签(head 头部必须)-->
<title>your title</title>
<!--页面关键词 keywords-->
<meta name="keywords" content="your keywords">
<!--页面描述内容 description-->
<meta name="description" content="your description">
<!--定义网页作者 author-->
<meta name="author" content="author,email address">
<!--定义网页搜索引擎索引方式,robotterms 是一组使用英文逗号「,」分割的值,通常有如下几种取值:none,noindex,nofollow,all,index和follow。-->
<meta name="robots" content="index,follow">

优先使用 IE 最新版本和 Chrome

1
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

charset 声明文档使用的字符编码

1
2
3
4
<meta charset="utf-8">
<!--html5 之前网页中会这样写:-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--这两个是等效的,具体可移步阅读:<meta charset='utf-8'> vs <meta http-equiv='Content-Type'>,所以建议使用较短的,易于记忆。-->

viewport模板——通用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<title>标题</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
这里开始内容
</body>
</html>

HTML meta refresh 刷新与跳转(重定向)页面

  • refresh 属性值 – 刷新与跳转(重定向)页面
  • refresh用于刷新与跳转(重定向)页面
  • refresh出现在http-equiv属性中,使用content属性表示刷新或跳转的开始时间与跳转的网址

refresh示例
5秒之后刷新本页面:

1
<meta http-equiv="refresh" content="5" />

5秒之后转到梦之都首页:

1
<meta http-equiv="refresh" content="5; url=https://www.baidu.com/" />

vincentSea wechat
一颗稻草的价值,到底是多少呢?想知道的话,就订阅吧!