--- title: <head> slug: Web/HTML/Element/head tags: - HTML - HTML 文档元数据 - Web - head - 元素 - 参考 translation_of: Web/HTML/Element/head --- <h2 id="概述">概述</h2> <p><strong>HTML head 元素 </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("title")}} 元素来指定文档的标题信息,除非标题已经从更高等级协议中指定({{HTMLElement("iframe")}} )。</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>一个由空格分隔的 URL 列表,这些 URL 包含着有关页面的配置信息。</dd> </dl> <h2 id="示例">示例</h2> <pre class="brush: html"><html> <head> <title>文档标题</title> </head> </html> </pre> <h2 id="附注">附注</h2> <p>如果在文档中忽略了 <code><head></code> 标签,则大部分浏览器会自动创建一个 <code><head></code> 元素。<a class="external" href="http://www.stevesouders.com/blog/2010/05/12/autohead-my-first-browserscope-user-test/">当然,有一些不会</a>。<br> 下面这些浏览器经测试不会自动创建一个 head 元素:Android <=1.6, iPhone <=3.1.3, Nokia 90, Opera <=9.27, and Safari <=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', '<head>')}}</td> <td>{{Spec2('HTML WHATWG')}}</td> <td>自上一次快照后未改变</td> </tr> <tr> <td>{{SpecName('HTML5 W3C', 'document-metadata.html#the-head-element', '<head>')}}</td> <td>{{Spec2('HTML5 W3C')}}</td> <td>废弃 <code>profile</code></td> </tr> <tr> <td>{{SpecName('HTML4.01', 'struct/global.html#h-7.4.1', '<head>')}}</td> <td>{{Spec2('HTML4.01')}}</td> <td> </td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> <p>{{Compat("html.elements.head")}}</p> <h2 id="相关链接">相关链接</h2> <ul> <li> <div id="main"> <div class="main_right"> <div class="target_lang" id="targetlang" style="BACKGROUND: none transparent scroll repeat 0% 0%;">可用于<head>元素内的元素有: {{HTMLElement("title")}}, {{HTMLElement("base")}}, {{HTMLElement("link")}}, {{HTMLElement("style")}}, {{HTMLElement("meta")}}, {{HTMLElement("script")}}, {{HTMLElement("noscript")}}, {{HTMLElement("command")}}</div> </div> </div> </li> </ul> <div>{{HTMLRef}}</div>