--- title:
slug: Web/HTML/Element/section tags: - Element - HTML - 区块 translation_of: Web/HTML/Element/section ---
{{HTMLRef}}

HTML <section>元素表示一个包含在HTML文档中的独立部分,它没有更具体的语义元素来表示,一般来说会有包含一个标题。

{{EmbedInteractiveExample("pages/tabbed/section.html", "tabbed-standard")}}

例如,导航菜单应该包含在{{htmlelement("nav")}}元素中,但搜索结果列表和地图显示及其控件没有特定元素,可以放在<section>里。

注意:如果元素的内容作为一个独立的有意义的集合,{{HTMLElement("article")}}元素可能是更好的选择。

内容分类 Flow content, Sectioning content, palpable content.
允许的内容 Flow content.
标签省略 {{no_tag_omission}}
允许的父元素 Any element that accepts flow content. Note that a <section> element must not be a descendant of an {{HTMLElement("address")}} element.
允许的 ARIA roles {{ARIARole("alert")}}, {{ARIARole("alertdialog")}}, {{ARIARole("application")}}, {{ARIARole("banner")}}, {{ARIARole("complementary")}}, {{ARIARole("contentinfo")}}, {{ARIARole("dialog")}}, {{ARIARole("document")}}, {{ARIARole("feed")}}, {{ARIARole("log")}}, {{ARIARole("main")}}, {{ARIARole("marquee")}}, {{ARIARole("navigation")}}, {{ARIARole("search")}}, {{ARIARole("status")}}, {{ARIARole("tabpanel")}}
DOM 接口 {{domxref("HTMLElement")}}

属性

此元素只包含  全局属性

使用说明

范例1:

之前

<div>
  <h1>Heading</h1>
  <p>Bunch of awesome content</p>
</div>

之后

<section>
  <h1>Heading</h1>
  <p>Bunch of awesome content</p>
</section>

范例2:

之前

<div>
  <h2>Heading</h2>
  <img src="bird.jpg" alt="bird">
</div>

之后

<section>
  <h2>Heading</h2>
  <img src="bird.jpg" alt="bird">
</section>

规范

规范 状态 注释
{{SpecName('HTML WHATWG', 'sections.html#the-section-element', '<section>')}} {{Spec2('HTML WHATWG')}}
{{SpecName('HTML5.1', 'sections.html#the-section-element', '<section>')}} {{Spec2('HTML5.1')}}
{{SpecName('HTML5 W3C', 'sections.html#the-section-element', '<section>')}} {{Spec2('HTML5 W3C')}}

浏览器兼容性

{{Compat("html.elements.section")}}

参见