码迷,mamicode.com
首页 > Web开发 > 详细

html头部meta属性大全——各种奇葩属性设置大归类

时间:2018-03-16 14:01:24      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:前端开发 html标签设置

常用通用属性:

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

<!--设置屏幕缩放-->

<link rel="dns-prefetch" href="//www.zhoulujun.cn">

<!--设置dns缓存-->

<meta name="applicable-device" content="pc,mobile">

<!--设置支持终端-->

网页相关信息设置

<meta name="keywords" content="周陆军“/>

<!--设置网页关键词,SEO-->

<meta name="description" content="周陆军网站"/>

<!--设置网页内容描述,SEO-->

<meta name="author" content="周陆军"/>

<!--设置网页作者-->

<meta name="generator"content="信息参数"/>

<!--说明网站的采用的什么软件制作-->

<meta name='Copyright' content='zhoulujun'>

<!--说明网站版权信息-->

<meta name="revisit-after" content="7days"'>

<!--revisit-after代表网站重访,7days代表7天,依此类推。-->

http-equiv属性

<meta http-equiv="expires"content="Fri,12Jan200118:18:18GMT">

<!--可以用于设定网页的到期时间。一旦网页过期,必须到服务器上重新传输。-->

<meta http-equiv="Pragma"content="no-cache">

<!--禁止浏览器从本地计算机的缓存中访问页面内容。-->

<meta http-equiv="Refresh"content="2;URL=haorooms.com">

<!--自动刷新并指向新页面。其中的2是指停留2秒钟后自动刷新到URL网址。-->

<meta http-equiv="Set-Cookie"content="cookie value=xxx;expires=Friday,12-Jan-200118:18:18GMT;path=/">

<!--如果网页过期,那么存盘的cookie将被删除。注意:必须使用GMT的时间格式。-->

<meta http-equiv="content-Type"content="text/html;charset=gb2312">

<!--设定页面使用的字符集。-->

<meta http-equiv="Content-Language"content="zh-cn"/>

<!--设定显示语言-->

<Meta http-equiv="Content-Script-Type"Content="text/javascript">

<!--指明页面中脚本的类型-->

IOS的头部设置

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

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

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

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

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

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

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

<!-- 设置苹果工具栏颜色 -->

iOS 图标设置

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

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

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

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

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

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

iOS 启动画面

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

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

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

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

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

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

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

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

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

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

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

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

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

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

一些特殊浏览器的设置:

QQ浏览器相关设置:

<meta name="x5-orientation" content="portrait">

<!-- QQ强制竖屏 -->

<meta name="x5-fullscreen" content="true">

<!-- QQ强制全屏 -->

<meta name="x5-page-mode" content="app">

<!-- QQ应用模式 -->

UC浏览器相关设置:    

<!-- UC强制竖屏 -->

<meta name="screen-orientation" content="portrait">

<!-- UC强制全屏 -->

<meta name="full-screen" content="yes">

<!-- UC应用模式 -->

<meta name="browsermode" content="application">

360浏览器:

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

<!-- 启用360浏览器的极速模式(webkit) -->

windows相关设备:

<meta name="msapplication-tap-highlight" content="no">

<!-- windows phone 点击无高光 -->

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

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

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

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

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

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

<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>

<!-- 添加 favicon icon -->

其他设备设置:

<meta name="HandheldFriendly" content="true">

<!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 -->

最后讲讲常用的老浏览器霸主IE

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

<!-- 避免IE使用兼容模式 -->

X-UA-Compatible是神马?

X-UA-Compatible是IE8的一个专有<meta>属性,它告诉IE8采用何种IE版本去渲染网页,在html的<head>标签中使用。可以在微软官方文档获取更多介绍。

为什么要用X-UA-Compatible?

在IE8刚推出的时候,很多网页由于重构的问题,无法适应较高级的浏览器,所以使用X-UA-Compatible标签强制IE8采用低版本方式渲染。

使用下面这段代码后,开发者无需考虑网页是否兼容IE8浏览器,只要确保网页在IE6、IE7下的表现就可以了。

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

使用下面这段代码使用的是Edge 。模式Edge 模式告诉 IE 以最高级模式渲染文档,也就是任何 IE 版本都以当前版本所支持的最高级标准模式渲染,避免版本升级造成的影响。简单的说,就是什么版本 IE        就用什么版本的标准模式渲染。

<meta http-equiv="X-UA-Compatible" content="IE=edge">

使用以下代码强制 IE 使用 Chrome Frame 渲染

<meta http-equiv="X-UA-Compatible" content="chrome=1">

最佳的兼容模式方案:

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

ps:为防止失效,X-UA-Compatible最好紧跟在head之后,之前不要有任何不标准的标签。



下面是配置大全

<link rel="dns-prefetch" href="//www.zhoulujun.cn">
<!--设置dns缓存-->
<meta name="applicable-device" content="pc,mobile">
<!--设置支持终端-->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<!--设置屏幕缩放-->
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
<!--设定页面使用的字符集。-->
<meta http-equiv="Content-Language" content="zh-cn"/>
<!--设定显示语言-->



<meta name="keywords" content="周陆军"/>
<!--设置网页关键词,SEO-->
<meta name="description" content="周陆军网站"/>
<!--设置网页内容描述,SEO-->
<meta name="author" content="周陆军"/>
<!--设置网页作者-->
<meta name="generator" content="intellij"/>
<!--说明网站的采用的什么软件制作-->
<meta name='Copyright' content='zhoulujun'>
<!--说明网站版权信息-->


<meta name="apple-mobile-web-app-title" content="周陆军的个人网站">
<!-- 添加到主屏后的标题(iOS 6 新增) -->
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!-- 是否启用 WebApp 全屏模式,删除苹果默认的工具栏和菜单栏 -->
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=http://www.zhoulujun.cn">
<!-- 添加智能 App 广告条 Smart App Banner(iOS 6+ Safari) -->
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<!-- 设置苹果工具栏颜色 -->


<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png"/>
<!-- iPhone 和 iTouch,默认 57x57 像素,必须有 -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png"/>
<!-- Retina iPhone 和 Retina iTouch,114x114 像素,可以没有,但推荐有 -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png"/>
<!-- Retina iPad,144x144 像素,可以没有,但推荐有 -->






<meta name="x5-orientation" content="portrait">
<!-- QQ强制竖屏 -->
<meta name="x5-fullscreen" content="true">
<!-- QQ强制全屏 -->
<meta name="x5-page-mode" content="app">
<!-- QQ应用模式 -->


<!-- UC强制竖屏 -->
<meta name="screen-orientation" content="portrait">
<!-- UC强制全屏 -->
<meta name="full-screen" content="yes">
<!-- UC应用模式 -->
<meta name="browsermode" content="application">

<meta name="renderer" content="webkit">
<!-- 启用360浏览器的极速模式(webkit) -->


<meta name="msapplication-tap-highlight" content="no">
<!-- windows phone 点击无高光 -->
<meta name="msapplication-TileColor" content="#000"/>
<!-- Windows 8 磁贴颜色 -->
<meta name="msapplication-TileImage" content="icon.png"/>
<!-- Windows 8 磁贴图标 -->
<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml"/>
<!-- 添加 RSS 订阅 -->
<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>
<!-- 添加 favicon icon -->


<meta name="HandheldFriendly" content="true">
<!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 -->



参考文章:    http://www.bubblypoker.com/2016/11/07/h5%E5%A4%B4%E9%83%A8meta%E6%95%B4%E7%90%86/

cnblogs.com/nidilzhang/

cnblogs.com/chendc/p/54

转载请注明文章出处:html头部meta属性大全--各种奇葩属性设置大归类 - html5 - 周陆军的个人网站


html头部meta属性大全——各种奇葩属性设置大归类

标签:前端开发 html标签设置

原文地址:http://blog.51cto.com/zhoulujun/2087527

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!