史上最全的meta大全

2022年7月5日21:13  0  2  

meta标签提供关于HTML文档的元数据。元数据不会显示在页面上,但是对于机器是可读的。它可用于浏览器(如何显示内容或重新加载页面),搜索引擎(关键词),或其他 web 服务。 

必要属性

属性描述
contentsome text定义与http-equiv或name属性相关的元信息

可选属性

属性描述
http-equivcontent-type / expire / refresh / set-cookie把content属性关联到HTTP头部。
nameauthor / description / keywords / generator / revised / others把 content 属性关联到一个名称。
contentsome text定义用于翻译 content 属性值的格式。

 

SEO相关:

1、页面关键词,每个网页应具有描述该网页内容的一组唯一的关键字。 

<meta name="keywords" content="your tags" />

2、页面描述,每个网页都应有一个不超过 150 个字符且能准确反映网页内容的描述标签。

<meta name="description" content="150 words" />

3、搜索引擎索引方式

<meta name="robots" content="index,follow" /><!--
    all:文件将被检索,且页面上的链接可以被查询;
    none:文件将不被检索,且页面上的链接不可以被查询;
    index:文件将被检索;
    follow:页面上的链接可以被查询;
    noindex:文件将不被检索;
    nofollow:页面上的链接不可以被查询。
 -->

4、页面重定向和刷新:content内的数字代表时间(秒),既多少时间后刷新。如果加url,则会重定向到指定网页(搜索引擎能够自动检测,也很容易被引擎视作误导而受到惩罚)

<meta http-equiv="refresh" content="0;url=" />

5、其它

<meta name="author" content="author name" /> <!-- 定义网页作者 --><meta name="google" content="index,follow" /><meta name="googlebot" content="index,follow" /><meta name="verify" content="index,follow" />

设计坞官网https://www.wode007.com/sites/73738.html

移动设备:

1、viewport:能优化移动浏览器的显示。如果不是响应式网站,不要使用initial-scale或者禁用缩放。大部分4.7-5寸设备的viewport宽设为360px;5.5寸设备设为400px;iphone6设为375px;ipone6 plus设为414px。

<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
  1. width:宽度(数值 / device-width)(范围从200 到10,000,默认为980 像素)
  2. height:高度(数值 / device-height)(范围从223 到10,000)
  3. initial-scale:初始的缩放比例 (范围从>0 到10)
  4. minimum-scale:允许用户缩放到的最小比例
  5. maximum-scale:允许用户缩放到的最大比例
  6. user-scalable:用户是否可以手动缩 (no,yes)
  7. minimal-ui:可以在页面加载时最小化上下状态栏。(已弃用)

注意,很多人使用initial-scale=1到非响应式网站上,这会让网站以100%宽度渲染,用户需要手动移动页面或者缩放。如果和initial-scale=1同时使用user-scalable=no或maximum-scale=1,则用户将不能放大/缩小网页来看到全部的内容。

2、WebApp全屏模式:伪装app,离线应用。

<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- 启用 WebApp 全屏模式 -->

3、隐藏状态栏/设置状态栏颜色:只有在开启WebApp全屏模式时才生效。content的值为default | black | black-translucent 。

<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

4、添加到主屏后的标题

<meta name="apple-mobile-web-app-title" content="标题">

5、忽略数字自动识别为电话号码

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

6、忽略识别邮箱

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

7、添加智能 App 广告条 Smart App Banner:告诉浏览器这个网站对应的app,并在页面上显示下载banner(如下图)。参考文档

<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">

8、其他

<!-- 针对手持设备优化,主要是针对一些老的不识别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">

 

网页相关

1、申明编码

<meta charset='utf-8' />

2、优先使用 IE 最新版本和 Chrome

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><!-- 关于X-UA-Compatible --><meta http-equiv="X-UA-Compatible" content="IE=6" ><!-- 使用IE6 --><meta http-equiv="X-UA-Compatible" content="IE=7" ><!-- 使用IE7 --><meta http-equiv="X-UA-Compatible" content="IE=8" ><!-- 使用IE8 -->

3、浏览器内核控制:国内浏览器很多都是双内核(webkit和Trident),webkit内核高速浏览,IE内核兼容网页和旧版网站。而添加meta标签的网站可以控制浏览器选择何种内核渲染。参考文档

<meta name="renderer" content="webkit|ie-comp|ie-stand">

国内双核浏览器默认内核模式如下:
1. 搜狗高速浏览器、QQ浏览器:IE内核(兼容模式)
2. 360极速浏览器、遨游浏览器:Webkit内核(极速模式)

4、禁止浏览器从本地计算机的缓存中访问页面内容:这样设定,访问者将无法脱机浏览。

<meta http-equiv="Pragma" content="no-cache">
5、Windows 8
<meta name="msapplication-TileColor" content="#000"/> <!-- Windows 8 磁贴颜色 --><meta name="msapplication-TileImage" content="icon.png"/> <!-- Windows 8 磁贴图标 -->

6、站点适配:主要用于PC-手机页的对应关系。

<meta name="mobile-agent"content="format=[wml|xhtml|html5]; url=url"><!--
[wml|xhtml|html5]根据手机页的协议语言,选择其中一种;
url="url" 后者代表当前PC页所对应的手机页URL,两者必须是一一对应关系。
 -->

7、转码申明:用百度打开网页可能会对其进行转码(比如贴广告),避免转码可添加如下meta。

<meta http-equiv="Cache-Control" content="no-siteapp" />

 


<!-- 定义文档的字符编码 -->

<meta charset="utf-8" /> 

<!-- 强制Chromium内核,作用于360浏览器、QQ浏览器等国产双核浏览器 -->

<meta name="renderer" content="webkit"/>

<!-- 强制Chromium内核,作用于其他双核浏览器 -->

<meta name="force-rendering" content="webkit"/>

<!-- 如果有安装 Google Chrome Frame 插件则强制为Chromium内核,否则强制本机支持的最高版本IE内核,作用于IE浏览器 -->

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

<!-- 

    设置视窗大小

    width    设置layout viewport  的宽度,为一个正整数,或字符串"width-device"

    initial-scale    设置页面的初始缩放值,为一个数字,可以带小数

    minimum-scale    允许用户的最小缩放值,为一个数字,可以带小数

    maximum-scale    允许用户的最大缩放值,为一个数字,可以带小数

    shrink-to-fit=no IOS9中要想前面的属性起作用需要加上这个

    height    设置layout viewport  的高度,这个属性对我们并不重要,很少使用

    user-scalable    是否允许用户进行缩放,值为"no"或"yes", no 代表不允许,yes代表允许

-->

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

<!-- 页面描述 -->

<meta name="description" content="不超过150个字符"/>

<!-- 页面关键词 -->

<meta name="keywords" content=""/>

<!-- 网页作者 -->

<meta name="author" content="name, email@gmail.com"/>

<!-- 

    搜索引擎抓取

    all:文件将被检索,且页面上的链接可以被查询; 

    none:文件将不被检索,且页面上的链接不可以被查询;

    index:文件将被检索; 

    follow:页面上的链接可以被查询; 

    noindex:文件将不被检索; 

    nofollow:页面上的链接不可以被查询。 

-->

<meta name="robots" content="index,follow"/>

<!-- 忽略页面中的数字识别为电话,忽略email识别-->

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


<!-- IOS begin -->

<!-- 添加到主屏后的标题(iOS 6 新增) -->

<meta name="apple-mobile-web-app-title" content="标题">

<!-- 当网站添加到主屏幕快速启动方式,可隐藏地址栏,仅针对ios的safari (ios7.0版本以后,safari上已看不到效果) -->

<meta name="apple-mobile-web-app-capable" content="yes"/>

<!-- 是否启用 WebApp 全屏模式,删除苹果默认的工具栏和菜单栏 -->

<meta name="apple-touch-fullscreen" content="yes"/>

<!-- 添加智能 App 广告条 Smart App Banner(iOS 6+ Safari) -->

<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">

<!-- 设置苹果工具栏颜色:默认值为 default(白色),可以定为 black(黑色)和 black-translucent(灰色半透明) -->

<meta name="apple-mobile-web-app-status-bar-style" content="black"/>

<!-- 不让百度转码 -->

<meta http-equiv="Cache-Control" content="no-siteapp" />

<!-- 针对手持设备优化,主要是针对一些老的不识别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">


<!-- 

    iOS 图标 begin 

    网站添加至ios桌面时的图标

-->

<!-- iPhone 和 iTouch,默认 57x57 像素,必须有 -->

<link rel="apple-touch-icon-precomposed" sizes="57x57" href="table_ico57.png">

<!-- Retina iPhone 和 Retina iTouch,114x114 像素,可以没有,但推荐有 -->

<link rel="apple-touch-icon-precomposed" sizes="72x72" href="table_ico72.png">

<link rel="apple-touch-icon-precomposed" sizes="114x114" href="table_ico114.png">

<!-- Retina iPad,144x144 像素,可以没有,但推荐有 -->

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="table_ico144.png">


<!-- iOS 启动画面 begin -->

<!-- iPad 竖屏 768 x 1004(标准分辨率) -->

<link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png"/>

<!-- iPad 横屏 1024x748(标准分辨率) -->

<link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png"/>

<!-- iPad 竖屏 1536x2008(Retina) -->

<link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png"/>

<!-- iPad 横屏 2048x1496(Retina) -->

<link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png"/>

<!-- iPhone/iPod Touch 竖屏 320x480 (标准分辨率) -->

<link rel="apple-touch-startup-image" href="/splash-screen-320x480.png"/>

<!-- iPhone/iPod Touch 竖屏 640x960 (Retina) -->

<link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png"/>

<!-- iPhone 5/iPod Touch 5 竖屏 640x1136 (Retina) -->

<link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png"/>

<!-- IOS end -->


<!-- Windows 8 磁贴颜色 -->

<meta name="msapplication-TileColor" content="#000"/>

<!-- Windows 8 磁贴图标 -->

<meta name="msapplication-TileImage" content="icon.png"/>

<!-- 添加 RSS 订阅 -->

<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml"/>


<!-- sns 社交标签 begin -->

<!-- 参考微博API -->

<meta property="og:type" content="类型" />

<meta property="og:url" content="URL地址" />

<meta property="og:title" content="标题" />

<meta property="og:image" content="图片" />

<meta property="og:description" content="描述" />

<!-- sns 社交标签 end -->


继续阅读