Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1067526 of <head>

  • 版本网址缩略名: Web/HTML/Element/head
  • 版本标题: <head>
  • 版本 id: 1067526
  • 创建于:
  • 创建者: jesse0x90
  • 是否是当前版本?
  • 评论

修订内容

概述

HTML Head 元素 (<head>) 规定文档相关的通用信息(元数据),包括文档标题、样式或脚本的链接或定义。

  • 内容类别
  • 允许内容如果元素是 {{HTMLElement("iframe")}} {{htmlattrxref("srcdoc", "iframe")}}, 或者如果来自更高等级协议、零个或更多元数据内容的元素的标题信息可用 。
    否则,一个或更多元数据内容的元素中确切的一个是{{HTMLElement("title")}} 元素。
  • 标签省略 如果在<head>元素中的第一个是个元素则开始标签可被省略
    如果跟在<head>元素后的第一个不是空白字符或注释则结束标签可被省略
  • 允许父元素一个{{HTMLElement("html")}} 元素,作为它的第一个子元素
  • DOM 接口 {{domxref("HTMLHeadElement")}}

属性

该元素包含全局属性

{{htmlattrdef("profile")}} {{HTMLVersionInline(4)}} only, {{obsolete_inline}} in {{HTMLVersionInline(5)}}
以空白符分隔的,一个或多个元数据档案的 URI。

示例

<html>
  <head>
    <title>文档标题</title>
  </head>
</html>

附注

如果在文档中忽略了 <head> 标签,则大部分浏览器会自动创建一个 <head> 元素。当然,有一些不会
下面这些浏览器经测试不会自动创建一个 head 元素:Android <=1.6, iPhone <=3.1.3, Nokia 90, Opera <=9.27, and Safari <=3.2.1。

规范

Specification Status Comment
{{SpecName('HTML WHATWG', 'semantics.html#the-head-element', '<head>')}} {{Spec2('HTML WHATWG')}} 自上一次快照后未改变
{{SpecName('HTML5 W3C', 'document-metadata.html#the-head-element', '<head>')}} {{Spec2('HTML5 W3C')}} 过时的简介
{{SpecName('HTML4.01', 'struct/global.html#h-7.4.1', '<head>')}} {{Spec2('HTML4.01')}}  

浏览器兼容性

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

相关链接

  • Elements that can be used inside a <head> element: {{HTMLElement("title")}}, {{HTMLElement("base")}}, {{HTMLElement("link")}}, {{HTMLElement("style")}}, {{HTMLElement("meta")}}, {{HTMLElement("script")}}, {{HTMLElement("noscript")}}, {{HTMLElement("command")}}
{{HTMLRef}}

修订版来源

<h2 id="概述">概述</h2>

<p><em>HTML Head 元素</em> (<strong>&lt;head&gt;</strong>) 规定文档相关的通用信息(元数据),包括文档标题、样式或脚本的链接或定义。</p>

<ul class="htmlelt">
 <li><dfn><a href="/en-US/docs/HTML/Content_categories" title="HTML/Content_categories">内容类别</a></dfn> 无</li>
 <li><dfn>允许内容</dfn>如果元素是 {{HTMLElement("iframe")}} {{htmlattrxref("srcdoc", "iframe")}}, 或者如果来自更高等级协议、零个或更多元数据内容的元素的标题信息可用&nbsp;。<br />
  否则,一个或更多元数据内容的元素中确切的一个是{{HTMLElement("title")}} 元素。</li>
 <li><dfn>标签省略</dfn> 如果在&lt;head&gt;元素中的第一个是个元素则开始标签可被省略<br />
  如果跟在&lt;head&gt;元素后的第一个不是空白字符或注释则结束标签可被省略</li>
 <li><dfn>允许父元素</dfn>一个{{HTMLElement("html")}} 元素,作为它的第一个子元素</li>
 <li><dfn>DOM 接口</dfn> {{domxref("HTMLHeadElement")}}</li>
</ul>

<h2 id="属性">属性</h2>

<p><span style="line-height:21px">该元素包含</span><a href="https://developer.mozilla.org/zh-CN/docs/HTML/Global_attributes" style="line-height: 21px;" title="HTML/Global attributes">全局属性</a><span style="line-height:21px">。</span></p>

<dl>
 <dt>{{htmlattrdef("profile")}} {{HTMLVersionInline(4)}} only, {{obsolete_inline}} in {{HTMLVersionInline(5)}}</dt>
 <dd>以空白符分隔的,一个或多个元数据档案的 URI。</dd>
</dl>

<h2 id="示例">示例</h2>

<pre class="brush: html">
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;文档标题&lt;/title&gt;
  &lt;/head&gt;
&lt;/html&gt;
</pre>

<h2 id="附注">附注</h2>

<p>如果在文档中忽略了 <code>&lt;head&gt;</code> 标签,则大部分浏览器会自动创建一个 <code>&lt;head&gt;</code> 元素。<a class="external" href="https://www.stevesouders.com/blog/2010/05/12/autohead-my-first-browserscope-user-test/" title="https://www.stevesouders.com/blog/2010/05/12/autohead-my-first-browserscope-user-test/">当然,有一些不会</a>。<br />
 下面这些浏览器经测试不会自动创建一个 head 元素:Android &lt;=1.6, iPhone &lt;=3.1.3, Nokia 90, Opera &lt;=9.27, and Safari &lt;=3.2.1。</p>

<h2 id="Specifications" name="Specifications">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'semantics.html#the-head-element', '&lt;head&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>自上一次快照后未改变</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'document-metadata.html#the-head-element', '&lt;head&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>过时的简介</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML4.01', 'struct/global.html#h-7.4.1', '&lt;head&gt;')}}</td>
   <td>{{Spec2('HTML4.01')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>1.0</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE&nbsp;Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>Elements that can be used inside a <span style="font-family:courier new">&lt;head&gt;</span> element:&nbsp;{{HTMLElement("title")}}, {{HTMLElement("base")}}, {{HTMLElement("link")}}, {{HTMLElement("style")}}, {{HTMLElement("meta")}}, {{HTMLElement("script")}}, {{HTMLElement("noscript")}}, {{HTMLElement("command")}}</li>
</ul>

<div>{{HTMLRef}}</div>
恢复到这个版本