<hgroup> HTML 元素代表文档标题和与标题相关联的内容,它将一个 <h1>–<h6> 元素与一个或多个 <p> 元素组合在一起。
{{InteractiveExample("HTML Demo: <hgroup>", "tabbed-standard")}}
```html interactive-example
Or: The Modern PrometheusFrankenstein
Victor Frankenstein, a Swiss scientist, has a great ambition: to create intelligent life. But when his creature first stirs, he realizes he has made a monster. A monster which, abandoned by his master and shunned by everyone who sees it, follows Dr Frankenstein to the very ends of the earth.
```css interactive-example
hgroup {
text-align: right;
padding-right: 16px;
border-right: 10px solid #00c8d7;
}
hgroup h1 {
margin-bottom: 0;
}
hgroup p {
margin: 0;
font-weight: bold;
}
属性
这个元素仅包含全局属性。
使用说明
<hgroup> 元素允许将一个标题与任意次要内容(例如子标题、副标题或口号)组合在一起。在 <hgroup> 中,这些类型的内容也表示为 <p> 元素。
<hgroup> 本身对网页的文档大纲没有任何影响。而 <hgroup> 中所允许的单个标题则会被用于文档大纲。
示例
<!doctype html>
<title>HTML 标准</title>
<body>
<hgroup id="document-title">
<h1>HTML:现行标准</h1>
<p>更新于 2022 年 7 月 12 日</p>
</hgroup>
<p>文档的介绍。</p>
<h2>目录</h2>
<ol id="toc">
…
</ol>
<h2>第一节</h2>
<p>第一节的介绍。</p>
</body>
无障碍考虑
目前,<hgroup> 没有无障碍的语义。只有其中的元素(标题和可选的段落)会被暴露给浏览器的无障碍 API。
技术概要
| 内容分类 | 流式内容、标题内容、可感知内容。 |
|---|---|
| 允许的内容 | 零个或多个 {{HTMLElement("p")}} 元素,后跟一个 {{HTMLElement("h1")}}、{{HTMLElement("h2")}}、{{HTMLElement("h3")}}、{{HTMLElement("h4")}}、{{HTMLElement("h5")}} 或 {{HTMLElement("h6")}} 元素,后跟零个或多个 {{HTMLElement("p")}} 元素。 |
| 标签省略 | 不允许,开始标签和结束标签都不能省略。 |
| 允许的父元素 | 任何接受流式内容的元素。 |
| 隐式 ARIA 角色 | 没有对应的角色 |
| 允许的 ARIA 角色 | 任意 |
| DOM 接口 | HTMLElement |