--- title: <header> slug: Web/HTML/Element/header tags: - HTML - HTML sections - 元素 translation_of: Web/HTML/Element/header --- <div>{{HTMLRef}}</div> <p><strong>HTML <code><header></code> 元素</strong>用于展示介绍性内容,通常包含一组介绍性的或是辅助导航的实用元素。它可能包含一些标题元素,但也可能包含其他元素,比如 Logo、搜索框、作者名称,等等。</p> <div>{{EmbedInteractiveExample("pages/tabbed/header.html", "tabbed-standard")}}</div> <p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples </a> and send us a pull request.</p> <table class="properties"> <tbody> <tr> <th scope="row"><a href="/zh-CN/docs/HTML/Content_categories">内容类型</a></th> <td><a href="/zh-CN/docs/HTML/Content_categories#Flow_content">Flow content</a>,palpable content。</td> </tr> <tr> <th scope="row">许可内容</th> <td><a href="/zh-CN/docs/HTML/Content_categories#Flow_content">Flow content</a>,但是不允许 <code><header></code> 或{{HTMLElement("footer")}} 成为子元素</td> </tr> <tr> <th scope="row">标记省略</th> <td>{{no_tag_omission}}</td> </tr> <tr> <th scope="row">允许的父元素</th> <td>任何接受 <a href="/zh-CN/docs/HTML/Content_categories#Flow_content">flow content</a> 的元素。注意 <code><header></code> 元素不能作为 {{HTMLElement("address")}}、{{HTMLElement("footer")}} 或另一个 {{HTMLElement("header")}} 元素的子元素。</td> </tr> <tr> <th scope="row">允许的 ARIA 角色</th> <td>{{ARIARole("group")}},{{ARIARole("presentation")}}</td> </tr> <tr> <th scope="row">DOM 接口</th> <td>{{domxref("HTMLElement")}}</td> </tr> </tbody> </table> <h2 id="使用提示">使用提示</h2> <p><code><header></code> 元素不是分段内容,因此不会往 <a href="/zh-CN/docs/Web/Guide/HTML/Sections_and_Outlines_of_an_HTML5_document">大纲</a> 中引入新的段落。也就是说,<code><header></code> 元素通常用于包含周围部分的标题(<code>h1</code> 至 <code>h6</code> 元素),但这<strong>不是</strong>必需的。</p> <h2 id="属性">属性</h2> <p>此元素仅拥有 <a href="/zh-CN/docs/HTML/Global_attributes"> 全局属性</a>。</p> <h2 id="示例">示例</h2> <h3 id="页面的_Header">页面的 Header</h3> <pre class="brush: html"><header> <h1>主页标题</h1> <img src="mdn-logo-sm.png" alt="MDN logo"> </header> </pre> <h3 id="文章的_Header">文章的 Header</h3> <pre class="brush: html"><article> <header> <h2>The Planet Earth</h2> <p>Posted on Wednesday, 4 October 2017 by Jane Smith</p> </header> <p>We live on a planet that's blue and green, with so many things still unseen.</p> <p><a href="https://janesmith.com/the-planet-earth/">Continue reading....</a></p> </article> </pre> <h2 id="规范">规范</h2> <table class="standard-table"> <thead> <tr> <th scope="col">规范</th> <th scope="col">状态</th> <th scope="col">备注</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('HTML WHATWG', 'semantics.html#the-header-element', '<header>')}}</td> <td>{{Spec2('HTML WHATWG')}}</td> <td> </td> </tr> <tr> <td>{{SpecName('HTML5 W3C', 'sections.html#the-header-element', '<header>')}}</td> <td>{{Spec2('HTML5 W3C')}}</td> <td> </td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("html.elements.header")}}</p> <h2 id="参见">参见</h2> <ul> <li>Others section-related elements: {{HTMLElement("body")}}, {{HTMLElement("nav")}}, {{HTMLElement("article")}}, {{HTMLElement("aside")}}, {{HTMLElement("h1")}}, {{HTMLElement("h2")}}, {{HTMLElement("h3")}}, {{HTMLElement("h4")}}, {{HTMLElement("h5")}}, {{HTMLElement("h6")}}, {{HTMLElement("hgroup")}}, {{HTMLElement("footer")}}, {{HTMLElement("section")}}, {{HTMLElement("address")}};</li> <li class="last"><a class="deki-ns current" href="/en-US/docs/Web/Guide/HTML/Sections_and_Outlines_of_an_HTML5_document">Sections and outlines of an HTML5 document</a>.</li> </ul>