之前咱们经常使用的是 <html lang="zh-CN">
或简写的 <html lang="zh">
,但实际上 W3 language tags 推荐使用 zh-Hans 简体中文
、zh-Hant 繁体中文
,能够提升一致性和准确。html
1.声明文档使用的字符编码android
<meta charset="utf-8">
用于 HTML5
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
用于 HTML4
或者 XHTML
或用于过期的 dom 解析器一般咱们会使用短的。实际上,在 `HTML5` 中,以上两种是等价的,只是短的更容易被记住。更多对比见 [stackoverflow](https://stackoverflow.com/questions/4696499/meta-charset-utf-8-vs-meta-http-equiv-content-type)
2.优先使用 IE 最新版本和 Chromeios
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
3.360 使用 Google Chrome Framegit
<!-- 若是没有安装 GCF(Google Chrome Frame),使用最高版本的IE内核渲染 --> <meta name="renderer" content="webkit" /> <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
具体详情见 360 浏览器内核控制github
<!-- 强制使用webkit渲染 --> <meta name="renderer" content="webkit"> <meta name="force-rendering" content="webkit">
4.百度禁止转码
在使用百度移动搜索时,百度会自动将网站进行转码,添加一些烦人的广告,若是咱们不作百度广告,是能够经过 meta
标签禁止网站被转码web
<meta http-equiv="Cache-Control" content="no-transform" /> <meta http-equiv="Cache-Control" content="no-siteapp" /> <!-- 表示页面同时适合在移动设备和PC上进行浏览 --> <meta name="applicable-device" content="pc,mobile">
相关网站:chrome
5.SEO 优化windows
<title>your title</title>
<meta name="keywords" content="your keywords">
<meta name="description" content="your description">
<meta name="author" content="author,email address">
<meta name="robots" content="index,follow">

6.为移动设备添加 viewport
,可让布局在移动浏览器上显示的更好浏览器
<meta name ="viewport" content =" width=device-width, initial-scale=1.0, maximum-scale=3.0, minimum-scale=1.0, user-scalable=no " >
width=device-width
会致使 iPhone5 添加到主屏后以 WebApp 全屏模式打开页面时出现黑边cookie
注意: minimal-ui
iOS8 中已经删除
7.ios 设备
<meta name="apple-mobile-web-app-title" content="标题">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!-- 在 "apple-mobile-web-app-capable" content="yes" 时生效 --> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
[content 参数](http://blog.jayself.com/2014/03/22/meta/) ``` default 默认值。 black 状态栏背景是黑色。 black-translucent 状态栏背景是黑色半透明。 若是设置为 default 或 black ,网页内容从状态栏底部开始。 若是设置为 black-translucent ,网页内容充满整个屏幕,顶部会被状态栏遮挡。 ``` - 禁止数字识自动别为电话号码 ```html <meta name="format-detection" content="telephone=no" /> <!-- 电话号码、邮箱 --> <meta name="format-detection" content="telephone=no,email=no" /> ``` - 添加智能 App 广告条 Smart App Banner(iOS 6+ Safari) ```html <meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL" > ``` content 属性能够传三个参数,以逗号隔开: ``` app-id(必选) 填写应用在APPStrore的ID affiliate-data(可选) 是iTunes 分销联盟计划的ID 通常用不到。 app-argument(可选)点击『打开』给APP传参数 ```
8.关闭 chrome 浏览器下翻译插件
<meta name="google" value="notranslate" />
9.去除手机半透明背景
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
meta
标签去除<meta name="msapplication-tap-highlight" content="no">
注意:部分机型可能去除不了,若是是按钮,能够避免使用 `a`、`input`,使用 `div` 代替
10.刷新浏览器
content -- 时间;网址
<meta http-equiv="Refresh" content="2;URL=http://www.baidu.com">
11.强制竖屏与全屏
landscape -- 横屏;portrait -- 竖屏
<!-- 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">
12.应用模式
<!-- UC应用模式:默认全屏,禁止长按菜单,禁止手势,标准排版,强制图片显示 --> <meta name="browsermode" content="application"> <!-- QQ应用模式 --> <meta name="x5-page-mode" content="app">
browsermode
做用:
<!-- UC使用适屏模式显示 --> <meta name="layoutmode" content="fitscreen"> <!-- UC强制图片显示 --> <meta name="imagemode" content="force"> <!-- UC禁止夜间模式显示 enable|disable --> <meta name="nightmode" content="disable"> <!-- UC当页面有太多文字时禁止缩放 --> <meta name="wap-font-scale" content="no">
13.UC排版模式
UC 浏览器提供两种排版模式,分别是适屏模式(fitscreen)及标准模式(standard),其中适屏模式简化了一些页面的处理,使得页面内容更适合进行页面阅读、节省流量及响应更快,而标准模式则能按照标准规范对页面进行排版及渲染。
<meta name="layoutmode" content="fitscreen|standard">
14.cookie 设定指定时间后删除
<!-- Set-Cookie(cookie设定):若是网页过时,那么存盘的cookie将被删除 GMT格式 --> <meta http-equiv="Set-Cookie" content="cookie value=xxx;expires=Friday,12-Jan-200118:18:18GMT;path=/" >