2017 HTML 标签中<head> 元素指南

2017-09-06 22:38:00 3243 5 编辑:Monster 来源:HTML5+CSS3

最小推荐

下面是基本的、最低限度的网站基本标签:

HTML 代码:

<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>


网页元素

HTML 代码:

<!-- 文档标题 -->

<title>页面标题</title>

 

<!-- 基本 URL 作用于文档中所包含的所有相对 URL -->

<base href="https://szhulian.com/page.html">

 

<!-- 外部的 CSS -->

<link rel="stylesheet" href="styles.css">

 

<!-- 文档内的 CSS -->

<style>

  /* ... */

</style>

 

<!-- JavaScript -->

<script src="script.js"></script>

<noscript><!--无 JS 时的替代--></noscript>



Meta 标签

HTML 代码:

<!-- 设置文档的字符编码 -->

<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" -->


链接

HTML 代码:

<!-- 表明一个 CSS 样式表 -->

<link rel="stylesheet" href="https://szhulian.com/styles.css">

 

<!-- 有助于防止出现内容重复的问题 -->

<link rel="canonical" href="https://szhulian.com/2010/06/9-things-to-do-before-entering-social-media.html">

 

<!-- 之前用于包含 icon 链接,但已被废弃并不再使用 -->

<link rel="shortlink" href="https://szhulian.com/?p=42">

 

<!-- 链接到当前文档的一个 AMP HTML 版本 -->

<link rel="amphtml" href="https://szhulian.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.szhulian.com/" hreflang="es">

 

<!-- 提供了关于作者或其他人的信息 -->

<link rel="me" href="https://google.com/profiles/thenextweb" type="text/html">

<link rel="me" href="mailto:name@szhulian.com">

<link rel="me" href="sms:+15035550125">

 

<!-- 链接到一个描述历史记录、文档或其他具有历史意义的材料的集合的文档。 -->

<link rel="archives" href="https://szhulian.com/archives/">

 

<!-- 链接到层次结构中的顶级资源 -->

<link rel="index" href="https://szhulian.com/">

 

<!-- 给出一个自我参考 - 当文档有多个可能的参考时非常有用 -->

<link rel="self" type="application/atom+xml" href="https://szhulian.com/atomFeed.php?page=3">

 

<!-- 分别是在一系列文件中的第一个、下一个、上一个和最后一个 -->

<link rel="first" href="https://szhulian.com/atomFeed.php">

<link rel="next" href="https://szhulian.com/atomFeed.php?page=4">

<link rel="prev" href="https://szhulian.com/atomFeed.php?page=2">

<link rel="last" href="https://szhulian.com/atomFeed.php?page=147">

 

<!-- 当使用第三方服务来维护 blog 时使用 -->

<link rel="EditURI" href="https://szhulian.com/xmlrpc.php?rsd" type="application/rsd+xml" title="RSD">

 

<!-- 当另一个 WordPress 博客链接到你的 WordPress 博客或文章时形成一个自动化的评论 -->

<link rel="pingback" href="https://szhulian.com/xmlrpc.php">

 

<!-- 当你在自己的页面上链接到一个 url 时通知它 -->

<link rel="webmention" href="https://szhulian.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/szhulian" type="application/rss+xml" title="RSS">

<link rel="alternate" href="https://szhulian.com/feed.atom" type="application/atom+xml" title="Atom 0.3">

 

<!-- 预取,预载,预浏览 -->

<link rel="dns-prefetch" href="//szhulian.com/">

<link rel="preconnect" href="https://www.szhulian.com/">

<link rel="prefetch" href="https://www.szhulian.com/">

<link rel="prerender" href="https://szhulian.com/">

<link rel="preload" href="image.png" as="image">

本站文章均为深正网站建设摘自权威资料,书籍,或网络原创文章,如有版权纠纷或者违规问题,请即刻联系我们删除,我们欢迎您分享,引用和转载,但谢绝直接搬砖和抄袭!感谢...
关注深正互联

15

技术从业经验

多一份方案,会有收获...

联系深正互联,免费获得专属《策划方案》及报价

在线咨询
微信交谈
拒绝骚扰,我们只想为给您带来一些惊喜...
多一份免费策划方案,总有益处。

请直接添加技术总监微信联系咨询

深正互联微信
扫描即可沟通