HTML | 2017年最新的 <head> 元素指南

整理了一份关于可以写入到HTML 标签中的内容清单-2017年最新的 <head>元素指南,主要内容来自 <head> cheatsheet ,让大家了解每个标签及相应属性的意义,写出满足自己需求的 <head>头部标签,可以很有效的增强页面的可用性。

最小推荐

<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- 以上 3 个 meta 标签 *必须* 放在 head 的最前面;其他任何的 head 内容必须在这些标签的 *后面* -->
<title>页面标题</title>

网页元素

<!-- 文档标题 -->
<title>页面标题</title>
 
<!-- 基本 URL 作用于文档中所包含的所有相对 URL -->
<base href="https://example.com/page.html">
 
<!-- 外部的 CSS -->
<link rel="stylesheet" href="styles.css">
 
<!-- 文档内的 CSS -->
<style>
  /* ... */
</style>
 
<!-- JavaScript -->
<script src="script.js"></script>
<noscript><!--无 JS 时的替代--></noscript>

Meta 标签

<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- 以上 3 个 meta 标签 *必须* 放在 head 的最前面;其他任何的 head 内容必须在这些标签的 *后面* -->
 
<!-- 对外部资源加载的限制(允许控制从哪里加载资源) -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
<!-- 尽早地放置在文档中 -->
<!-- 仅应用于该标签下的内容 -->
 
<!-- Web 应用的名称(仅当网站被用作为一个应用时才使用)-->
<meta name="application-name" content="应用名称">
 
<!-- 针对页面的简短描述(限制 150 字符)-->
<!-- 在*某些*情况下,该描述是被用作搜索结果展示片段的一部分 -->
<meta name="description" content="一个页面描述">
 
<!-- 控制搜索引擎的抓取和索引行为 -->
<meta name="robots" content="index,follow"><!-- 所有搜索引擎 -->
<meta name="googlebot" content="index,follow"><!-- 仅对 Google 有效 -->
 
<!-- 告诉 Google 不显示网站链接的搜索框 -->
<meta name="google" content="nositelinkssearchbox">
 
<!-- 告诉 Google 不提供此页面的翻译 -->
<meta name="google" content="notranslate">
 
<!-- 验证 Google 搜索控制台的所有权 -->
<meta name="google-site-verification" content="verification_token">
 
<!-- 验证 Yandex 网站管理员的所有权 -->
<meta name="yandex-verification" content="verification_token">
 
<!-- 验证 Bing 网站管理员中心的所有权 -->
<meta name="msvalidate.01" content="verification_token">
 
<!-- 验证 Alexa 控制台的所有权 -->
<meta name="alexaVerifyID" content="verification_token">
 
<!-- 验证 Pinterest 控制台的所有权 -->
<meta name="p:domain_verify" content="code from pinterest">
 
<!-- 验证 Norton 安全站点的所有权 -->
<meta name="norton-safeweb-site-verification" content="norton code">
 
<!-- 用来命名软件或用于构建网页(如 - WordPress、Dreamweaver)-->
<meta name="generator" content="program">
 
<!-- 关于你的网站主题的简短描述 -->
<meta name="subject" content="你的网站主题">
 
<!-- 基于网站内容给出一般的年龄分级 -->
<meta name="rating" content="General">
 
<!-- 允许控制 referrer 信息如何传递 -->
<meta name="referrer" content="no-referrer">
 
<!-- 禁用自动检测和格式化可能的电话号码 -->
<meta name="format-detection" content="telephone=no">
 
<!-- 通过设置为 “off” 完全退出 DNS 预取 -->
<meta http-equiv="x-dns-prefetch-control" content="off">
 
<!-- 在客户端存储 cookie,web 浏览器的客户端识别 -->
<meta http-equiv="set-cookie" content="name=value; expires=date; path=url">
 
<!-- 指定要显示在一个特定框架中的页面 -->
<meta http-equiv="Window-Target" content="_value">
 
<!-- 地理标签 -->
<meta name="ICBM" content="latitude, longitude">
<meta name="geo.position" content="latitude;longitude">
<meta name="geo.region" content="country[-state]"><!-- 国家代码 (ISO 3166-1): 强制性, 州代码 (ISO 3166-2): 可选; 如 content="US" / content="US-NY" -->
<meta name="geo.placename" content="city/town"><!-- 如 content="New York City" -->

Google 可以识别的 Meta 标签
WHATWG Wiki: Meta 拓展
ICBM – 维基百科
地理标记 – 维基百科

链接

<!-- 表明一个 CSS 样式表 -->
<link rel="stylesheet" href="https://example.com/styles.css">
 
<!-- 有助于防止出现内容重复的问题 -->
<link rel="canonical" href="https://example.com/2010/06/9-things-to-do-before-entering-social-media.html">
 
<!-- 之前用于包含 icon 链接,但已被废弃并不再使用 -->
<link rel="shortlink" href="https://example.com/?p=42">
 
<!-- 链接到当前文档的一个 AMP HTML 版本 -->
<link rel="amphtml" href="https://example.com/path/to/amp-version.html">
 
<!-- 链接到一个指定 Web 应用程序“安装”证书的 JSON 文件 -->
<link rel="manifest" href="manifest.json">
 
<!-- 链接到文档的作者 -->
<link rel="author" href="humans.txt">
 
<!-- 指向一个适用于链接内容的版权申明 -->
<link rel="license" href="copyright.html">
 
<!-- 给出可能的你的另一种语言的文档位置参考 -->
<link rel="alternate" href="https://es.example.com/" hreflang="es">
 
<!-- 提供了关于作者或其他人的信息 -->
<link rel="me" href="https://google.com/profiles/thenextweb" type="text/html">
<link rel="me" href="mailto:name@example.com">
<link rel="me" href="sms:+15035550125">
 
<!-- 链接到一个描述历史记录、文档或其他具有历史意义的材料的集合的文档。 -->
<link rel="archives" href="https://example.com/archives/">
 
<!-- 链接到层次结构中的顶级资源 -->
<link rel="index" href="https://example.com/">
 
<!-- 给出一个自我参考 - 当文档有多个可能的参考时非常有用 -->
<link rel="self" type="application/atom+xml" href="https://example.com/atomFeed.php?page=3">
 
<!-- 分别是在一系列文件中的第一个、下一个、上一个和最后一个 -->
<link rel="first" href="https://example.com/atomFeed.php">
<link rel="next" href="https://example.com/atomFeed.php?page=4">
<link rel="prev" href="https://example.com/atomFeed.php?page=2">
<link rel="last" href="https://example.com/atomFeed.php?page=147">
 
<!-- 当使用第三方服务来维护 blog 时使用 -->
<link rel="EditURI" href="https://example.com/xmlrpc.php?rsd" type="application/rsd+xml" title="RSD">
 
<!-- 当另一个 WordPress 博客链接到你的 WordPress 博客或文章时形成一个自动化的评论 -->
<link rel="pingback" href="https://example.com/xmlrpc.php">
 
<!-- 当你在自己的页面上链接到一个 url 时通知它 -->
<link rel="webmention" href="https://example.com/webmention">
 
<!-- 加载一个外部的 HTML 文件到当前 HTML 文件中 -->
<link rel="import" href="/path/to/component.html">
 
<!-- 打开搜索 -->
<link rel="search" href="/open-search.xml" type="application/opensearchdescription+xml" title="Search Title">
 
<!-- Feeds -->
<link rel="alternate" href="https://feeds.feedburner.com/example" type="application/rss+xml" title="RSS">
<link rel="alternate" href="https://example.com/feed.atom" type="application/atom+xml" title="Atom 0.3">
 
<!-- 预取,预载,预浏览 -->
<link rel="dns-prefetch" href="//example.com/">
<link rel="preconnect" href="https://www.example.com/">
<link rel="prefetch" href="https://www.example.com/">
<link rel="prerender" href="https://example.com/">
<link rel="preload" href="image.png" as="image">
<!-- 更多信息:https://css-tricks.com/prefetching-preloading-prebrowsing/ -->

网站图标

<!-- 针对 IE 10 及以下版本 -->
<!-- 如果将 `favicon.ico` 放在根目录下,则无需标签 -->
 
<!-- 对于 IE 11、Chrome、Firefox、Safari 和 Opera -->
<link rel="icon" type="image/png" sizes="16x16" href="/path/to/favicon-16x16.png"/>
<link rel="icon" type="image/png" sizes="32x32" href="/path/to/favicon-32x32.png"/>
<link rel="icon" type="image/png" sizes="96x96" href="/path/to/favicon-96x96.png"/>
<!-- 更多信息: https://bitsofco.de/all-about-favicons-and-touch-icons/ -->

所有关于网站图标(和触摸图标)的信息
网站图标对照表

社交

Facebook Open Graph

<meta property="fb:app_id" content="123456789"/>
<meta property="og:url" content="https://example.com/page.html"/>
<meta property="og:type" content="website"/>
<meta property="og:title" content="Content Title"/>
<meta property="og:image" content="https://example.com/image.jpg"/>
<meta property="og:description" content="Description Here"/>
<meta property="og:site_name" content="Site Name"/>
<meta property="og:locale" content="en_US"/>
<meta property="article:author" content=""/>

Facebook 的 Open Graph 的标记
Open Graph 协议

Facebook Instant Articles

<meta charset="utf-8"/>
<meta property="op:markup_version" content="v1.0"/>
 
<!-- 你的文章的 Web 版网址 -->
<link rel="canonical" href="http://example.com/article.html"/>
 
<!-- 用于该文章的样式 -->
<meta property="fb:article_style" content="myarticlestyle"/>

Facebook Instant Articles: 创建文章
Instant Articles: 格式参考

Twitter Cards

<meta name="twitter:card" content="summary"/>
<meta name="twitter:site" content="@site_account"/>
<meta name="twitter:creator" content="@individual_account"/>
<meta name="twitter:url" content="https://example.com/page.html"/>
<meta name="twitter:title" content="Content Title"/>
<meta name="twitter:description" content="Content description less than 200 characters"/>
<meta name="twitter:image" content="https://example.com/image.jpg"/>

Twitter 名片:入门指南
Twitter 名片验证

Google+ / Schema.org

<link href="https://plus.google.com/+YourPage" rel="publisher"/>
<meta itemprop="name" content="内容标题"/>
<meta itemprop="description" content="内容描述少于 200 个字符"/>
<meta itemprop="image" content="https://example.com/image.jpg"/>

OEmbed

<link rel="alternate" type="application/json+oembed"
  href="http://example.com/services/oembed?url=http%3A%2F%2Fexample.com%2Ffoo%2F&amp;format=json"
  title="oEmbed Profile: JSON"/>
<link rel="alternate" type="text/xml+oembed"
  href="http://example.com/services/oembed?url=http%3A%2F%2Fexample.com%2Ffoo%2F&amp;format=xml"
  title="oEmbed Profile: XML"/>

浏览器 / 平台

Apple iOS

<!-- 智能应用 Banner -->
<meta name="apple-itunes-app" content="app-id=APP_ID,affiliate-data=AFFILIATE_ID,app-argument=SOME_TEXT"/>
 
<!-- 禁用自动检测和格式化可能的电话号码 -->
<meta name="format-detection" content="telephone=no"/>
 
<!-- 添加到主屏幕 -->
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta name="apple-mobile-web-app-title" content="应用标题"/>
 
<!-- 触摸图标 -->
<!-- 在大多数情况下,在 `<head>` 中,一个 180×180px 触摸图标就已经足够了 -->
<link rel="apple-touch-icon" href="/path/to/apple-touch-icon.png"/>
<!-- 注意:iOS 7 上的 Safari 不会对图标产生效果。 -->
<!-- 较早版本的 Safari 不会对以 `-precomposed.png` 后缀命名的图标文件产生效果。 -->
 
<!-- 启动画面(已无效) -->
<link rel="apple-touch-startup-image" href="path/to/startup.png"/>
 
<!-- iOS 应用深层链接 -->
<meta name="apple-itunes-app" content="app-id=APP-ID, app-argument=http/url-sample.com"/>
<link rel="alternate" href="ios-app://APP-ID/http/url-sample.com"/>

Apple Meta 标签

Apple Safari

<!-- 固定网站 -->
<link rel="mask-icon" href="path/to/icon.svg" color="red"/>

Google Android

<meta name="theme-color" content="#E64545"/>
 
<!-- 添加到主屏幕 -->
<meta name="mobile-web-app-capable" content="yes"/>
<!-- 更多信息:https://developer.chrome.com/multidevice/android/installtohomescreen -->

Google Chrome

<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/APP_ID"/>
 
<!-- 禁用翻译提示 -->
<meta name="google" content="notranslate"/>

Microsoft Internet Explorer

<meta http-equiv="x-ua-compatible" content="ie=edge"/>
<meta name="skype_toolbar" content="skype_toolbar_parser_compatible"/>
 
<!-- IE10: 禁用链接点击高亮 (https://blogs.windows.com/buildingapps/2012/11/15/adapting-your-webkit-optimized-site-for-internet-explorer-10/) -->
<meta name="msapplication-tap-highlight" content="no"/>
 
<!-- 固定网站 (https://msdn.microsoft.com/en-us/library/dn255024(v=vs.85).aspx) -->
<meta name="application-name" content="Sample Title"/>
<meta name="msapplication-tooltip" content="A description of what this site does."/>
<meta name="msapplication-starturl" content="http://example.com/index.html?pinned=true"/>
<meta name="msapplication-navbutton-color" content="#FF3300"/>
<meta name="msapplication-window" content="width=800;height=600"/>
<meta name="msapplication-task" content="name=Task 1;action-uri=http://host/Page1.html;icon-uri=http://host/icon1.ico"/>
<meta name="msapplication-task" content="name=Task 2;action-uri=http://microsoft.com/Page2.html;icon-uri=http://host/icon2.ico"/>
<meta name="msapplication-badge" value="frequency=NUMBER_IN_MINUTES;polling-uri=http://example.com/path/to/file.xml"/>
<meta name="msapplication-TileColor" content="#FF3300"/>
<meta name="msapplication-TileImage" content="path/to/tileimage.jpg"/>
 
<meta name="msapplication-config" content="http://example.com/browserconfig.xml"/>
<meta name="msapplication-notification" content="frequency=60;polling-uri=http://example.com/livetile;polling-uri2=http://example.com/livetile2"/>
<meta name="msapplication-task-separator" content="1"/>

国内的浏览器

360 浏览器

<!-- 选择渲染引擎 -->
<meta name="renderer" content="webkit|ie-comp|ie-stand"/>

QQ 移动浏览器

<!-- 在指定方向上锁定屏幕(锁定横/竖屏) -->
<meta name="x5-orientation" content="landscape/portrait"/>
<!-- 全屏显示此页面 -->
<meta name="x5-fullscreen" content="true"/>
<!-- 页面将以“应用模式”显示(全屏等)-->
<meta name="x5-page-mode" content="app"/>

UC 移动浏览器

<!-- 在指定方向上锁定屏幕(锁定横/竖屏) -->
<meta name="screen-orientation" content="landscape/portrait"/>
<!-- 全屏显示此页面 -->
<meta name="full-screen" content="yes"/>
<!-- 即使在“文本模式”下,UC 浏览器也会显示图片 -->
<meta name="imagemode" content="force"/>
<!-- 页面将以“应用模式”显示(全屏、禁止手势等) -->
<meta name="browsermode" content="application"/>
<!-- 在此页面禁用 UC 浏览器的“夜间模式” -->
<meta name="nightmode" content="disable"/>
<!-- 简化页面,减少数据传输 -->
<meta name="layoutmode" content="fitscreen"/>
<!-- 禁用的 UC 浏览器的功能,“当此页面中有较多文本时缩放字体” -->
<meta name="wap-font-scale" content="no"/>

应用链接

<!-- iOS -->
<meta property="al:ios:url" content="applinks://docs"/>
<meta property="al:ios:app_store_id" content="12345"/>
<meta property="al:ios:app_name" content="App Links"/>
<!-- Android -->
<meta property="al:android:url" content="applinks://docs"/>
<meta property="al:android:app_name" content="App Links"/>
<meta property="al:android:package" content="org.applinks"/>
<!-- Web 回退 -->
<meta property="al:web:url" content="http://applinks.org/documentation"/>
<!-- 更多信息:http://applinks.org/documentation/ -->

应用链接文档

注意

性能

<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet"/>

其他资源

HTML5 样板文档:HTML 标签
HTML5 样板文档:扩展和定制

相关项目

Atom HTML Head 片段 – Atom HEAD
片段包
Sublime Text HTML Head 片段 – Sublime Text HEAD
片段包
head-it – HEAD
片段的 CLI 接口
vue-head – 在 Vue.js 中操作 HEAD
标签的 meta 信息

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,302评论 5 470
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,232评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,337评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,977评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,920评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,194评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,638评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,319评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,455评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,379评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,426评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,106评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,696评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,786评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,996评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,467评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,043评论 2 341

推荐阅读更多精彩内容