个人网站主页建设教程,浙江省住房城乡建设厅网站首页,网站优化排名方法有哪些,北京中文seo本文主要内容来自一丝的常用的 HTML 头部标签和百度FEX的HTML head 头标签。
移动端的工作已经越来越成为前端工作的重要内容#xff0c;除了平常的项目开发#xff0c;HTML 头部标签功能#xff0c;特别是meta标签显得非常重要。 DOCTYPE DOCTYPE(Document Type)#xff…本文主要内容来自一丝的常用的 HTML 头部标签和百度FEX的HTML head 头标签。
移动端的工作已经越来越成为前端工作的重要内容除了平常的项目开发HTML 头部标签功能特别是meta标签显得非常重要。 DOCTYPE DOCTYPE(Document Type)该声明位于文档中最前面的位置处于 html 标签之前此标签告知浏览器文档使用哪种 HTML 或者 XHTML 规范。
使用 HTML5 doctype不区分大小写。
!DOCTYPE html !-- 使用 HTML5 doctype不区分大小写 -- charset 声明文档使用的字符编码
meta charsetutf-8
html5 之前网页中会这样写
meta http-equivContent-Type contenttext/html; charsetutf-8
这两个是等效的具体可移步阅读meta charsetutf-8 vs meta http-equivContent-Type所以建议使用较短的易于记忆。 lang属性 更加标准的 lang 属性写法 网页头部的声明应该是用 langzh 还是 langzh-cn - 知乎
简体中文
html langzh-cmn-Hans !-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa --
繁体中文
html langzh-cmn-Hant !-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa --
很少情况才需要加地区代码通常是为了强调不同地区汉语使用差异例如
p langzh-cmn-Hans
strong langzh-cmn-Hans-CN菠萝/strong和strong langzh-cmn-Hant-TW鳳梨/strong其实是同一种水果。只是大陆和台湾称谓不同且新加坡、马来西亚一带的称谓也是不同的称之为strong langzh-cmn-Hans-SG黄梨/strong。
/p
为什么 langzh-cmn-Hans 而不是我们通常写的 langzh-CN 呢请移步阅读: 页头部的声明应该是用 lang”zh” 还是 lang”zh-cn”。 优先使用 IE 最新版本和 Chrome meta http-equivX-UA-Compatible contentIEedge,chrome1 / 360 使用Google Chrome Frame meta namerenderer contentwebkit
360 浏览器就会在读取到这个标签后立即切换对应的极速核。 另外为了保险起见再加入
meta http-equivX-UA-Compatible contentIEEdge,chrome1
这样写可以达到的效果是如果安装了 Google Chrome Frame则使用 GCF 来渲染页面如果没有安装 GCF则使用最高版本的 IE 内核进行渲染。 相关链接浏览器内核控制 Meta 标签说明文档 百度禁止转码 通过百度手机打开网页时百度可能会对你的网页进行转码脱下你的衣服往你的身上贴狗皮膏药的广告为此可在 head 内添加
meta http-equivCache-Control contentno-siteapp /
相关链接SiteApp 转码声明 SEO 优化部分 页面标题title标签(head 头部必须)
titleyour title/title
页面关键词 keywords
meta namekeywords contentyour keywords
页面描述内容 description
meta namedescription contentyour description
定义网页作者 author
meta nameauthor contentauthor,email address
定义网页搜索引擎索引方式robotterms 是一组使用英文逗号「,」分割的值通常有如下几种取值nonenoindexnofollowallindex和follow。
meta namerobots contentindex,follow
相关链接WEB1038 – 标记包含无效的值 为移动设备添加 viewport viewport可以让布局在移动浏览器上显示的更好。 通常会写
meta name viewport content initial-scale1, maximum-scale3, minimum-scale1, user-scalableno !-- widthdevice-width 会导致 iPhone 5 添加到主屏后以 WebApp 全屏模式打开页面时出现黑边 http://bigc.at/ios-webapp-viewport-meta.orz --
widthdevice-width 会导致 iPhone 5 添加到主屏后以 WebApp 全屏模式打开页面时出现黑边(WebAPP ViewPort iPhone5 黑边解决方案 – 大猫的无限游戏) content 参数
width viewport 宽度(数值/device-width)height viewport 高度(数值/device-height)initial-scale 初始缩放比例maximum-scale 最大缩放比例minimum-scale 最小缩放比例user-scalable 是否允许用户缩放(yes/no)minimal-ui iOS 7.1 beta 2 中新增属性注意iOS8 中已经删除可以在页面加载时最小化上下状态栏。这是一个布尔值可以直接这样写
meta nameviewport contentwidthdevice-width, initial-scale1, minimal-ui
而如果你的网站不是响应式的请不要使用 initial-scale 或者禁用缩放。
meta nameviewport contentwidthdevice-width,user-scalableyes
相关链接非响应式设计的viewport
适配 iPhone 6 和 iPhone 6plus 则需要写
meta nameviewport contentwidth375
meta nameviewport contentwidth414
大部分 4.7~5 寸的安卓设备的 viewport 宽设为 360pxiPhone 6 上却是 375px大部分 5.5 寸安卓机器比如说三星 Note的 viewport 宽为 400iPhone 6 plus 上是 414px。 ios 设备 添加到主屏后的标题iOS 6 新增
meta nameapple-mobile-web-app-title content标题 !-- 添加到主屏后的标题iOS 6 新增 --
是否启用 WebApp 全屏模式
meta nameapple-mobile-web-app-capable contentyes / !-- 是否启用 WebApp 全屏模式 --
设置状态栏的背景颜色
meta nameapple-mobile-web-app-status-bar-style contentblack-translucent / !-- 设置状态栏的背景颜色只有在 apple-mobile-web-app-capable contentyes 时生效 --
只有在 “apple-mobile-web-app-capable” content”yes” 时生效
content 参数
default 默认值。black 状态栏背景是黑色。black-translucent 状态栏背景是黑色半透明。 如果设置为 default 或 black ,网页内容从状态栏底部开始。如果设置为 black-translucent ,网页内容充满整个屏幕顶部会被状态栏遮挡。
禁止数字识自动别为电话号码
meta nameformat-detection contenttelephoneno / !-- 禁止数字识自动别为电话号码 -- iOS 图标 rel 参数 apple-touch-icon 图片自动处理成圆角和高光等效果。 apple-touch-icon-precomposed 禁止系统自动添加效果直接显示设计原图。 iPhone 和 iTouch默认 57×57 像素必须有
link relapple-touch-icon-precomposed href/apple-touch-icon-57x57-precomposed.png / !-- iPhone 和 iTouch默认 57x57 像素必须有 --
iPad72×72 像素可以没有但推荐有
link relapple-touch-icon-precomposed sizes72x72 href/apple-touch-icon-72x72-precomposed.png / !-- iPad72x72 像素可以没有但推荐有 --
Retina iPhone 和 Retina iTouch114×114 像素可以没有但推荐有
link relapple-touch-icon-precomposed sizes114x114 href/apple-touch-icon-114x114-precomposed.png / !-- Retina iPhone 和 Retina iTouch114x114 像素可以没有但推荐有 --
Retina iPad144×144 像素可以没有但推荐有
link relapple-touch-icon-precomposed sizes144x144 href/apple-touch-icon-144x144-precomposed.png / !-- Retina iPad144x144 像素可以没有但推荐有 --
IOS 图标大小在iPhone 6 plus上是180×180iPhone 6 是120×120。 适配iPhone 6 plus则需要在中加上这段
link relapple-touch-icon-precomposed sizes180x180 hrefretinahd_icon.png iOS 启动画面
官方文档Technical QA QA1686: App Icons on iPhone, iPad and Apple Watch 参考文章http://wxd.ctrip.com/blog/2013/09/ios7-hig-24/
iPad 的启动画面是不包括状态栏区域的。
iPad 竖屏 768 x 1004标准分辨率
link relapple-touch-startup-image sizes768x1004 href/splash-screen-768x1004.png / !-- iPad 竖屏 768 x 1004标准分辨率 --
iPad 竖屏 1536×2008Retina
link relapple-touch-startup-image sizes1536x2008 href/splash-screen-1536x2008.png / !-- iPad 竖屏 1536x2008Retina --
iPad 横屏 1024×748标准分辨率
link relapple-touch-startup-image sizes1024x748 href/Default-Portrait-1024x748.png / !-- iPad 横屏 1024x748标准分辨率 --
iPad 横屏 2048×1496Retina
link relapple-touch-startup-image sizes2048x1496 href/splash-screen-2048x1496.png / !-- iPad 横屏 2048x1496Retina --
iPhone 和 iPod touch 的启动画面是包含状态栏区域的。
iPhone/iPod Touch 竖屏 320×480 (标准分辨率)
link relapple-touch-startup-image href/splash-screen-320x480.png / !-- iPhone/iPod Touch 竖屏 320x480 (标准分辨率) --
iPhone/iPod Touch 竖屏 640×960 (Retina)
link relapple-touch-startup-image sizes640x960 href/splash-screen-640x960.png / !-- iPhone/iPod Touch 竖屏 640x960 (Retina) --
iPhone 5/iPod Touch 5 竖屏 640×1136 (Retina)
link relapple-touch-startup-image sizes640x1136 href/splash-screen-640x1136.png / !-- iPhone 5/iPod Touch 5 竖屏 640x1136 (Retina) --
添加智能 App 广告条 Smart App BanneriOS 6 Safari
meta nameapple-itunes-app contentapp-idmyAppStoreID, affiliate-datamyAffiliateData, app-argumentmyURL !-- 添加智能 App 广告条 Smart App BanneriOS 6 Safari --
iPhone 6对应的图片大小是750×1294iPhone 6 Plus 对应的是1242×2148 。
link relapple-touch-startup-image hreflaunch6.png media(device-width: 375px)
link relapple-touch-startup-image hreflaunch6plus.png media(device-width: 414px) Android Android Lollipop 中的 Chrome 39 增加 theme-color meta 标签用来控制选项卡颜色。
http://updates.html5rocks.com/2014/11/Support-for-theme-color-in-Chrome-39-for-Android meta nametheme-color content#db5945 rss订阅 link relalternate typeapplication/rssxml titleRSS href/rss.xml / !-- 添加 RSS 订阅 -- favicon icon link relshortcut icon typeimage/ico href/favicon.ico / !-- 添加 favicon icon --
比较详细的 favicon 介绍可参考https://github.com/audreyr/favicon-cheat-sheet 关闭chrome浏览器下翻译插件 有些时候感觉chrome浏览器下翻译插件很烦人可以通过下面的代码禁用它。
meta namegoogle valuenotranslate / 移动端的头部标签和meta !DOCTYPE html !-- 使用 HTML5 doctype不区分大小写 --
html langzh-cmn-Hans !-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa --
head!-- 声明文档使用的字符编码 --meta charsetutf-8!-- 优先使用 IE 最新版本和 Chrome --meta http-equivX-UA-Compatible contentIEedge,chrome1/!-- 页面描述 --meta namedescription content不超过150个字符/!-- 页面关键词 --meta namekeywords content/!-- 网页作者 --meta nameauthor contentname, emailgmail.com/!-- 搜索引擎抓取 --meta namerobots contentindex,follow/!-- 为移动设备添加 viewport --meta nameviewport contentinitial-scale1, maximum-scale3, minimum-scale1, user-scalableno!-- widthdevice-width 会导致 iPhone 5 添加到主屏后以 WebApp 全屏模式打开页面时出现黑边 http://bigc.at/ios-webapp-viewport-meta.orz --!-- iOS 设备 begin --meta nameapple-mobile-web-app-title content标题!-- 添加到主屏后的标题iOS 6 新增 --meta nameapple-mobile-web-app-capable contentyes/!-- 是否启用 WebApp 全屏模式删除苹果默认的工具栏和菜单栏 --meta nameapple-itunes-app contentapp-idmyAppStoreID, affiliate-datamyAffiliateData, app-argumentmyURL!-- 添加智能 App 广告条 Smart App BanneriOS 6 Safari --meta nameapple-mobile-web-app-status-bar-style contentblack/!-- 设置苹果工具栏颜色 --meta nameformat-detection contenttelphoneno, emailno/!-- 忽略页面中的数字识别为电话忽略email识别 --!-- 启用360浏览器的极速模式(webkit) --meta namerenderer contentwebkit!-- 避免IE使用兼容模式 --meta http-equivX-UA-Compatible contentIEedge!-- 针对手持设备优化主要是针对一些老的不识别viewport的浏览器比如黑莓 --meta nameHandheldFriendly contenttrue!-- 微软的老式浏览器 --meta nameMobileOptimized content320!-- uc强制竖屏 --meta namescreen-orientation contentportrait!-- QQ强制竖屏 --meta namex5-orientation contentportrait!-- UC强制全屏 --meta namefull-screen contentyes!-- QQ强制全屏 --meta namex5-fullscreen contenttrue!-- UC应用模式 --meta namebrowsermode contentapplication!-- QQ应用模式 --meta namex5-page-mode contentapp!-- windows phone 点击无高光 --meta namemsapplication-tap-highlight contentno!-- iOS 图标 begin --link relapple-touch-icon-precomposed href/apple-touch-icon-57x57-precomposed.png/!-- iPhone 和 iTouch默认 57x57 像素必须有 --link relapple-touch-icon-precomposed sizes114x114 href/apple-touch-icon-114x114-precomposed.png/!-- Retina iPhone 和 Retina iTouch114x114 像素可以没有但推荐有 --link relapple-touch-icon-precomposed sizes144x144 href/apple-touch-icon-144x144-precomposed.png/!-- Retina iPad144x144 像素可以没有但推荐有 --!-- iOS 图标 end --!-- iOS 启动画面 begin --link relapple-touch-startup-image sizes768x1004 href/splash-screen-768x1004.png/!-- iPad 竖屏 768 x 1004标准分辨率 --link relapple-touch-startup-image sizes1536x2008 href/splash-screen-1536x2008.png/!-- iPad 竖屏 1536x2008Retina --link relapple-touch-startup-image sizes1024x748 href/Default-Portrait-1024x748.png/!-- iPad 横屏 1024x748标准分辨率 --link relapple-touch-startup-image sizes2048x1496 href/splash-screen-2048x1496.png/!-- iPad 横屏 2048x1496Retina --link relapple-touch-startup-image href/splash-screen-320x480.png/!-- iPhone/iPod Touch 竖屏 320x480 (标准分辨率) --link relapple-touch-startup-image sizes640x960 href/splash-screen-640x960.png/!-- iPhone/iPod Touch 竖屏 640x960 (Retina) --link relapple-touch-startup-image sizes640x1136 href/splash-screen-640x1136.png/!-- iPhone 5/iPod Touch 5 竖屏 640x1136 (Retina) --!-- iOS 启动画面 end --!-- iOS 设备 end --meta namemsapplication-TileColor content#000/!-- Windows 8 磁贴颜色 --meta namemsapplication-TileImage contenticon.png/!-- Windows 8 磁贴图标 --link relalternate typeapplication/rssxml titleRSS href/rss.xml/!-- 添加 RSS 订阅 --link relshortcut icon typeimage/ico href/favicon.ico/!-- 添加 favicon icon --title标题/title
/head
更多的 meta 标签参考
COMPLETE LIST OF HTML META TAGS18 Meta Tags Every Webpage Should Have in 2013 参考文章
常用的 HTML 头部标签html5_headeramazeui cssDOCTYPEWEB 工程师和设计师必学的 10 个 IOS 8 新鲜改变