大网数据广告活动
Web 标准与前端开发

<hgroup>

· 52CE 我爱测

**`<hgroup>`** HTML 元素代表文档标题和与标题相关联的内容,它将一个 `<h1>–<h6>` 元素与一个或多个 `<p>` 元素组合在一起。

<hgroup> HTML 元素代表文档标题和与标题相关联的内容,它将一个 <h1>–<h6> 元素与一个或多个 <p> 元素组合在一起。

HTML Demo: <hgroup>

<hgroup>
  <h1>Frankenstein</h1>
  <p>Or: The Modern Prometheus</p>
</hgroup>
<p>
  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.
</p>
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。

技术概要

<table class="properties"> <tbody> <tr> <th scope="row"> <a href="/zh-CN/docs/Web/HTML/Guides/Content_categories" >内容分类</a > </th> <td> <a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#流式内容" >流式内容</a >、标题内容、可感知内容。 </td> </tr> <tr> <th scope="row">允许的内容</th> <td> 零个或多个 p 元素,后跟一个 h1、h2、h3、h4、h5 或 h6 元素,后跟零个或多个 p 元素。 </td> </tr> <tr> <th scope="row">标签省略</th> <td>不允许,开始标签和结束标签都不能省略。</td> </tr> <tr> <th scope="row">允许的父元素</th> <td> 任何接受<a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#流式内容" >流式内容</a >的元素。 </td> </tr> <tr> <th scope="row">隐式 ARIA 角色</th> <td> <a href="https://www.w3.org/TR/html-aria/#dfn-no-corresponding-role" >没有对应的角色</a > </td> </tr> <tr> <th scope="row">允许的 ARIA 角色</th> <td>任意</td> </tr> <tr> <th scope="row">DOM 接口</th> <td>HTMLElement</td> </tr> </tbody> </table>

规范

浏览器兼容性

参见

  • 与本章节相关的其他元素:body、article、section、aside、h1、h2、h3、h4、h5、h6、nav、header、footer、address;
  • HTML 文档的章节和大纲。

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。