即将是史上最全的meta大全

本文的目的是搜集当前主流的meta配置,方便开发者快速开发调试。在这里不会作各类meta的深刻分析,只是简单的介绍,让你们知道有这个东西。html

meta简述

  • meta用于描述 HTML 文档的元数据。一般用于指定网页的描述,关键词,做者及其余元数据。
  • 元数据能够被使用浏览器(如何显示内容或加载页面),搜索引擎(关键词),或其余 Web 服务调用。
  • meta从必定程度上影响seo

meta支持哪些属性

属性 描述
charset character_set 定义文档的字符编码。
content text 定义与 http-equiv 或 name 属性相关的元信息。
http-equiv content-type, default-style, refresh 把 content 属性关联到 HTTP 头部。
name application-name, author, description, generator, keywords 把 content 属性关联到一个名称。
scheme format/URI HTML5不支持。 定义用于翻译 content 属性值的格式。

http-equiv

meta标签上的http-equiv属性与http头部信息相关,并且是响应头,由于html本质上是经过服务器响应获得的。http-equiv用于假装 HTTP 响应头部信息。那么http-equiv有哪些类型呢?让咱们一块儿看下。前端

描述
cache-control 控制文档的缓存机制。容许的值以下:public:全部内容都将被缓存(客户端和代理服务器均可缓存);private:内容只缓存到私有缓存中(仅客户端能够缓存,代理服务器不可缓存);no-cache:不缓存,前提是经过服务器的缓存验证机制,如过时,内容改变等校验规则;no-store:全部内容都不会被缓存到缓存或 Internet 临时文件中(设置了貌似无效,仍是说不会出如今响应头吗?哪位大神能够解释下)
content-language 响应体的语言。如zh-CN, en-US(设置了貌似无效)
content-type 返回内容的MIME类型
date 原始服务器消息发出的时间,GMT时间格式
expires 响应过时的日期和时间,GMT时间格式<meta http-equiv="expires" content="Fri, 30 Dec 2011 12:00:00 GMT">(设置了貌似无效)
last-modified 请求资源的最后修改时间,GMT时间格式(设置了貌似无效)
location 用来重定向接收方到非请求URL的位置来完成请求或标识新的资源(设置了貌似无效)
refresh 定义间隔多久后刷新页面。单位是秒。
set-cookie 建立一个 cookie ,包含 cookie 名,cookie 值,过时时间。(设置了貌似无效)
window-target 用来防止别人在框架里调用本身的页面。<meta http-equiv="Window-target" content="_top">(设置了貌似无效)
Pragma 向后兼容只支持 HTTP/1.0 协议的缓存服务器,那时候 HTTP/1.1 协议中的 Cache-Control 尚未出来。<meta http-equiv="Pragma" content="no-cache">(设置了貌似无效)

注意:以上都是在chrome浏览器最新版本, vue dev环境下测试的,不表明全部浏览器和服务器表现。vue

常见meta

  1. 指定字符编码node

    <meta charset="UTF-8">
  2. IE杀手,推荐全部前端工程师采用,让咱们干掉IE的市场份额。webpack

    <!-- renderer适用于国产双内核浏览器 -->
    <!-- 使用Blink(Webkit) -->
    <meta name="renderer" content="webkit">
    <!-- IE兼容模式,使用ie低版本兼容 -->
    <meta name="renderer" content="ie-comp">
    <!-- IE标准模式,使用ie高版本兼容 -->
    <meta name="renderer" content="ie-stand">
    <!-- force-rendering适用于其余双内核浏览器 -->
    <meta name="force-rendering" content="webkit">
    <!-- 强化对IE的兼容性,强制IE使用最新版标准模式渲染或者使用Chrome Frame渲染 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  3. viewport常见设置,通常适用于移动端。视口宽度设为理想宽度,禁止缩放。web

    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
  4. meta三剑客chrome

    <meta name="description" content="Tusi博客,专一大前端技术架构与分享,关注用户体验">
    <meta name="keyword" content="Tusi博客,web前端,nodejs全栈,响应式,用户体验">
    <meta name="author" content="Tusi">
  5. UC浏览器私有metanpm

    <!-- 横屏/竖屏 -->
    <meta name="screen-orientation" content="landscape|portrait">
    <!-- 全屏 -->
    <meta name="full-screen" content="yes">
    <!-- 缩放不出滚动条 -->
    <meta name="viewport" content="uc-fitscreen=yes|no">
    <!-- 排版,fitscreen简化页面,适合阅读省流量,standard模式和标准浏览器一致 -->
    <meta name="layoutmode" content="fitscreen|standard" 
    <!-- 夜间模式的启用和禁用 -->
    <meta name="nightmode" content="enable|disable"/>
    <!-- 强制图片显示 -->
    <meta name="imagemode" content="force"/>
    <!-- 强制图片显示,只做用于单图 -->
    <img src="..." show="force">
    <!-- 应用模式,默认全屏,禁止长按菜单,禁止手势,标准排版,以及强制图片显示。 -->
    <meta name="browsermode" content="application">
  6. QQ浏览器X5内核私有meta(如今微信内置浏览器的内核也是X5哦)小程序

    <!-- 横屏/竖屏 -->
    <meta name="x5-orientation" content="landscape|portrait">
    <!-- 全屏 -->
    <meta name="x5-fullscreen" content="true">
    <!-- 应用模式 -->
    <meta name="x5-page-mode" content="app">
  7. 苹果机适配segmentfault

    <!-- "添加到主屏幕“后,全屏显示 -->
    <meta name="apple-touch-fullscreen" content="yes">
    <!-- 隐藏菜单栏和状态栏,相似于应用模式 -->
    <meta name="apple-mobile-web-app-capable" content="yes|no">
    <!-- 设置状态栏颜色,貌似只有default白色,black黑色,black-translucent灰色半透明 -->
    <meta name=”apple-mobile-web-app-status-bar-style” content=black”>
    <!-- 取消电话号码识别,防止误触拨号 -->
    <meta name="format-detection" content="telephone=no">
  8. 其余优化和适配手段

    <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,好比黑莓 -->
    <meta name="HandheldFriendly" content="true">
    
    <!-- 微软的老式浏览器 -->
    <meta name="MobileOptimized" content="320">
    
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no">
    
    <!-- robots 用来告诉搜索机器人哪些页面须要被检索 -->
    <!-- index 搜索引擎抓取这个页面 -->
    <!-- noindex 搜索引擎不抓取这个页面 -->
    <!-- follow 抓取外链 -->
    <!-- nofollow 不抓取外链 -->
    <meta name="robots" content="index,follow">
    <meta name="robots" content="index,nofollow">
    <meta name="robots" content="noindex,follow">
    <meta name="robots" content="noindex,nofollow">
    
    <!-- referrer 控制http请求头的referer,暂时没想到什么实际应用场景 -->
    <!-- no-referrer 不发referer -->
    <!-- origin 只发送origin部分 -->
    <!-- no-referrer-when-downgrade 默认值,当目的地是先验安全的(https->https)则发送origin做为 referrer,可是当目的地是较不安全的(https->http)时则不发送referrer -->。
    <!-- origin-when-crossorigin 在同源请求下,发送完整的URL(不含查询参数),其余状况下则仅发送当前文档的origin -->
    <!-- unsafe-URL 在同源请求下,发送完整的URL(不含查询参数) -->
    <meta name="referrer" content="no-referrer">
    
    <!-- og: Open Graph Protocol,一种友好的配置,让本身的网站在社交网络分享中更驾轻就熟,更多的配置能够去自行搜索 -->
    <!-- og:type 告诉SNS,我这是一个什么类型的网站 -->
    <meta property="og:type" content="article"/>
    <!-- og:title 告诉SNS,分享时告诉用户我这个网站的标题是什么,别本身瞎搞个标题 -->
    <meta property="og:title" content="Tusi博客"/>
    <meta property="og:url" content="https://blog.wbjiang.cn"/>
    <!-- og:image 缩略图 -->
    <meta property="og:image" content="/static/imgs/thumbnail.png"/>
    <meta property="og:description" content="专一于大前端技术架构与分享,关注用户体验"/>

首发连接


往期精彩:


扫一扫下方小程序码或搜索Tusi博客,即刻阅读最新文章!

Tusi博客

相关文章
相关标签/搜索