HEAD 介绍
能够放在文档的 <head> 中的各种配置元素
最小推荐
下面是基本的、最低限度的网站基本 标签 :
< Meta charset="utf-8">
< Meta http-equiv="x-ua-compatible" content="ie=edge">
< Meta name="viewport" content="width=device-width,initial-scale=1">
<!-- 以上 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-S ecurity -Policy" content="default-src 'self'">
<!-- 尽早地放置在文档中 -->
<!-- 仅应用于该 标签 下的 内容 -->
<!-- Web 应用的 名称 (仅当网站被用作为 一个 应用时才使用)-->
< Meta name="application-name" content="应用 名称 ">
<!-- 针对 页面 的简短描述(限制 150 字符)-->
<!-- 在*某些*情况下,该描述是被用作 搜索结果 展示片段的一部分 -->
< Meta name="description" content=" 一个 页面 描述">
<!-- 控制 搜索 引擎的抓取和索引行为 -->
< Meta name="robots" content="index,follow,noodp"><!-- 所有的 搜索 引擎 -->
< Meta name="googlebot" content="index,follow"><!-- 仅对 Google 有效 -->
<!-- 告诉 Google 不显示 网站 链接 的 搜索 框 -->
< Meta name="google" content="nositelinkssearch Box ">
<!-- 告诉 Google 不提供此 页面 的翻译 -->
< Meta name="google" content="notranslate">
<!-- 验证 Google 搜索 控制台的所有权 -->
< Meta name="google-site-verification" content="verification_token">
<!-- 用来命名软件或用于构建网页(如 - wordpress 、Dream weave r)-->
< Meta name="generator" content="program">
<!-- 关于你的网站 主题 的简短描述 -->
< Meta name="subject" content="你的网站 主题 ">
<!-- 非常简短(少于 10 个字)的描述。主要用于学术论文。-->
< Meta name="abstract" content="">
<!-- 完整的域名或网址 -->
< Meta name="url" content="https://example.com/">
< Meta name="directory" content="submission">
<!-- 基于网站 内容 给出一般的年龄分级 -->
< 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" -->
不推荐的 Meta 标签
以下是不推荐使用的 Meta 属性 ,因为它们采用率低,或已弃用:
<!-- 用于声明文档语言,但 支持 得不是很好。最好使用 <html lang=""> -->
< Meta name="language" content="en">
<!-- Google 无视 & Bing 认为 垃圾 的指示器 -->
< Meta name="keywords" content="你,关键字, 在这里 ,不使用空格,而用逗号进行分隔">
<!-- 目前没有在任何 搜索 引擎中使用过的声明 -->
< Meta name="revised" content="Sunday,July 18th,2010,5:15 pm">
<!-- 为 垃圾 邮件 机器人收获 email 地址提供了一种简单的方式 -->
< Meta name="reply-to" content="email@example.com">
<!-- 最好使用 <link rel="author"> 或 humans.txt 文件 -->
< Meta name="author" content="name,email@example.com">
< Meta name="designer" content="">
< Meta name="owner" content="">
<!-- 告诉 搜索 机器人一段时间后重新访问该网页。这 不支持 ,因为大多数 搜索 引擎使用 随机 时间间隔来重新抓取网页 -->
< Meta name="revisit-after" content="7 days">
<!-- 在一段时间后将 用户 重定向 到新的 URL -->
<!-- W3C 建议不要使用该 标签 。Google 建议使用服务器端的 301 重定向 。-->
< Meta http-equiv="refresh" content="300; url=https://example.com/">
<!-- 描述网站的 主题 -->
< Meta name="topic" content="">
<!-- 公司概要或网站目的 -->
< Meta name="summary" content="">
<!-- 一个 已废弃的 标签 ,和关键词 Meta 标签 的作用相同 -->
< Meta name="classification" content="busi nes s">
<!-- 是否是相同的 URL,年代久远且 不支持 -->
< Meta name="identifier-URL" content="https://example.com/">
<!-- 和关键词 标签 类似的 功能 -->
< Meta name="category" content="">
<!-- 确保你的网站在所有国家和语言中都能 显示 -->
< Meta name="coverage" content="Worldwide">
<!-- 和 coverage 标签 相同 -->
< Meta name=" dis tribution" content="Global">
<!-- 控制在互联网上哪些 用户 可以访问 -->
< Meta http-equiv="Pics-label" content="value">
<!-- 缓存控制 -->
<!-- 最好在服务器端配置缓存控制 -->
< Meta http-equiv="Expires" content="0">
< Meta http-equiv="Pragma" content="no-cache">
< Meta http-equiv="Cache-Control" content="no-cache">
链接
<!-- 有助于防止出现 内容 重复的问题 -->
<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">
<!-- 表明 一个 css 样式表 -->
<link rel="stylesheet" href="https://example.com/styles.css">
<!-- 链接 到 一个 指定 Web 应用程序“安装”证书的 jsON 文件 -->
<link rel="manifest" href="manifest.json">
<!-- 链接 到文档的作者 -->
<link rel="author" href="humans.txt">
<!-- 指向 一个 适用于 链接 内容 的版权申明 -->
<link rel=" cop yright" href=" cop yright.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/2003/05/" title="May 2003">
<!-- 链接 到层次结构中的顶级资源 -->
<link rel="index" href="https://example.com/" title="DeWitt Clinton">
<!-- 给出该文档的起点 -->
<link rel="start" href="https://example.com/photos/pattern_recognition_1_about/" title="Pattern Recognition 1">
<!-- 引导当前文档的前述资源序列 -->
<link rel="prev" href="https://example.com/opensearch/opensearch-and-openid-a-sure-way-to-get-my-attention/" title="OpenSearch and OpenID? A sure way to get my attention.">
<!-- 给出 一个 自我参考 - 当文档有多个可能的参考时非常有用 -->
<link rel="self" type="application/atom+xml" href="https://example.com/atom Feed . PHP ?page=3">
<!-- 分别是在一系列 文件 中的第 一个 、下 一个 、上 一个 和最后 一个 -->
<link rel="f irs t" href="https://example.com/atom Feed . PHP ">
<link rel="next" href="https://example.com/atom Feed . PHP ?page=4">
<link rel="prev IoU s" href="https://example.com/atom Feed . PHP ?page=2">
<link rel="last" href="https://example.com/atom Feed . 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="component.html">
<!-- 打开 搜索 -->
<link rel="search" href="/open-search.xml" type="application/opensearchdescription+xml" title="Search Title">
<!-- Feed s -->
<link rel="alternate" href="https:// Feed s. Feed burner.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 -pre bro wsing/ -->
不推荐的 链接
以下是不推荐使用的 链接 关系:
<link rel="shortcut icon" href="path/to/favicon.ico">
<!-- 没有用的,专有的和 错误 的,详见 https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/Y_2eFRh9BOs/gULYapoRBwAJ -->
<link rel="subresource" href="styles.css">
网站图标
<!-- 对于 IE10 及以下 -->
<!-- 无 链接 ,只需在根目录下放置名为 favicon.ico 的 文件 -->
<!-- 对于 IE 11、Chrome、Firefox、Safari 和 Opera -->
<link rel="icon" href="path/to/favicon-16.png" sizes="16x16" type="image/png">
<link rel="icon" href="path/to/favicon-32.png" sizes="32x32" type="image/png">
<link rel="icon" href="path/to/favicon-48.png" sizes="48x48" type="image/png">
<link rel="icon" href="path/to/favicon-62.png" sizes="62x62" type="image/png">
<link rel="icon" href="path/to/favicon-192.png" sizes="192x192" type="image/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: https://developers.facebook.com/docs/sharing/webmasters#markup -->
<!-- Open Graph: http://ogp.me/ -->
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">
< 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 ch ara cters">
< Meta name="twitter:image" content="https://example.com/image.jpg">
<!-- 更多信息: https://dev.twitter.com/cards/getting-started -->
<!-- 验证: https://dev.twitter.com/docs/cards/validation/validator -->
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">
根据他们的帮助中心可知,Pinterest 允许你 禁止 他人保存你网站里的 内容 。description?为可选。
< Meta name="pinterest" content=" nop in" description="Sorry,you can't save from my website!">
OEm bed
<link rel="alternate" type="application/json+oem bed "
href="http://example.com/services/oem bed ?url=http%3A%2F%2Fexample.com%2Ffoo%2F&format=json"
title="oEm bed Profile: jsON">
<link rel="alternate" type="text/xml+oem bed "
href="http://example.com/services/oem bed ?url=http%3A%2F%2Fexample.com%2Ffoo%2F&format=xml"
title="oEm bed Profile: XML">
浏览器 / 平台
Apple iOS
<!-- 智能应用 Banner -->
< Meta name="apple-itu nes -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="应用 标题 ">
<!-- 触摸图标 -->
<link rel="apple-touch-icon" href="path/to/apple-touch-icon.png">
<link rel="apple-touch-icon-p recompose d" href="path/to/apple-touch-icon-p recompose d.png">
<!-- iOS 8+ 不再 支持 预组合,你应该只使用 apple-touch-icon。-->
<!-- 在大多数情况下,在 `<head>` 中, 一个 180×180px 触摸图标就已经足够了 -->
<!-- 如果你想采用自适应的图标,可以设置多个尺寸的图标 -->
<link rel="apple-touch-icon" sizes="57x57" href="/path/to/icon@57.png">
<link rel="apple-touch-icon" sizes="72x72" href="/path/to/icon@72.png">
<link rel="apple-touch-icon" sizes="114x114" href="/path/to/icon@114.png">
<link rel="apple-touch-icon" sizes="144x144" href="//path/to/icon@144.png">
<!-- 启动画面(已无效) -->
<link rel="apple-touch-startup-image" href="path/to/startup.png">
<!-- iOS 应用深层 链接 -->
< Meta name="apple-itu nes -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 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/m ultidev ice/android/installtohomescreen -->
Google Chrome
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/APP_ID">
<!-- 禁用翻译 提示 -->
< Meta name="google" value="notranslate">
Google Chrome Mobile (只针对 Android)
从 Chrome 31 开始,你可以设置你的 Web 应用为“app mode”,如 Safari。
<!-- 链接 到 一个 manifest 并定义 manifest 的元数据。-->
<!-- manifest.json 中的例子也可以通过以下 链接 找到。-->
<link rel="manifest" href="manifest.json">
<!-- 定义你的网页为 Web 应用 -->
< Meta name="mobile-web-app-capable" content="yes">
<!-- 第 一个 是官方推荐格式。-->
<link rel="icon" sizes="192x192" href="nice-highres.png">
<link rel="icon" sizes="128x128" href="niceicon.png">
<!-- 所有带 apple 前缀的格式已废弃,所以不要使用它们。-->
<link rel="apple-touch-icon" sizes="128x128" href="niceicon.png">
<link rel="apple-touch-icon-p recompose d" sizes="128x128" href="niceicon.png">
Microsoft Internet Explorer
< Meta http-equiv="x-ua-compatible" content="ie=edge">
< Meta http-equiv="cleartype" content="on">
< Meta name="skype_toolbar" content="skype_toolbar_parser_compatible">
<!-- 在 Windows Phone 中的 IE 10 上禁用 链接 高亮 (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="Contoso Pinned Site Caption">
< Meta name="msapplication-tooltip" content="Example Tooltip Text">
< Meta name="msapplication-starturl" content="/">
< Meta name="msapplication-con fig " content="http://example.com/ bro wsercon fig .xml">
< Meta name="msapplication-allowDomainApiCalls" content="true">
< Meta name="msapplication-allowDomain Meta Tags" content="true">
< Meta name="msapplication-badge" content="frequency=30; polling-uri=http://example.com/id45453245/polling.xml">
< Meta name="msapplication-navbutton-color" content="#FF3300">
< Meta name="msapplication-notification" content="frequency=60;polling-uri=http://example.com/livetile">
< Meta name="msapplication-square150x150 logo " content="path/to/ logo .png">
< Meta name="msapplication-square310x310 logo " content="path/to/large logo .png">
< Meta name="msapplication-square70x70 logo " content="path/to/tiny logo .png">
< Meta name="msapplication-wide310x150 logo " content="path/to/wide logo .png">
< Meta name="msapplication-task" content="name=Check Order Status;action-uri=./orderStatus.aspx?src=IE9;icon-uri=./favicon.ico">
< Meta name="msapplication-task-sep ara tor" content="1">
< Meta name="msapplication-TileColor" content="#FF3300">
< Meta name="msapplication-TileImage" content="path/to/tileimage.jpg">
< Meta name="msapplication-window" content="width=1024;height=768">
Microsoft Internet Explorer: 传统,不要使用!
<!-- 在 IE 6 中,鼠标悬停在 图片 上时禁用图像工具栏 (https://msdn.microsoft.com/en-us/library/ms532986(v=vs.85).aspx) -->
< Meta http-equiv="imag eto olbar" content="no">
<!-- 禁用 Windows 主题 化的输入框/按钮 (https://support.microsoft.com/en-us/kb/322240) -->
< Meta name="MSThemeCompatible" content="no">
<!-- 禁用只在 IE 6 测试版中出现的 一个 功能 (https://stackoverflow.com/q/2167301) -->
< Meta name="MSSmartTagsPreventParsing" content="true">
<!-- 页间切换 (https://msdn.microsoft.com/en-us/library/ms532847(v=vs.85).aspx) -->
< Meta http-equiv="Page-Enter" content="revealtrans(duration=2,transition=2)">
< Meta http-equiv="Page-Exit" content="revealtrans(duration=3,transition=12)">
< Meta http-equiv="Site-Enter" content="revealtrans(duration=2,transition=2)">
< Meta http-equiv="Site-Exit" content="revealtrans(duration=3,transition=12)">
应用 链接
<!-- 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/ -->
国内的浏览器
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=" bro wsermode" content="application">
<!-- 在此 页面 禁用 UC 浏览器的“夜间模式” -->
< Meta name="nightmode" content=" dis able">
<!-- 简化 页面 ,减少数据传输 -->
< Meta name="layoutmode" content="fitscreen">
<!-- 禁用的 UC 浏览器的 功能 ,“当此 页面 中有较多文本时缩放字体” -->
< Meta name="wap-font-scale" content="no">
网站地址 : https://gethead.info
GitHub: https://github.com/joshbuchea/HEAD
网站描述: 一份你可以在 <head> 里设置的列表
HEAD官方网站
官方网站: https://gethead.info
如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。