Codectionary / Developer documentation / HTML

<hgroup>

The <hgroup> element groups a heading with one or more subheadings or taglines, treating them as a single unit in the document outline. It is commonly used to pair a main title with a subtitle, so the subtitle does not get counted as its own separate heading level by accessibility tools.

Syntax

<hgroup>
  <h1>Main Title</h1>
  <p>Subtitle or tagline</p>
</hgroup>

Examples

Title with Subtitle

Grouping a page title with a descriptive subtitle.

<hgroup>
  <h1>Codectionary</h1>
  <p>Learn to code, one tag at a time.</p>
</hgroup>

Article Title with Byline

Using hgroup for an article heading and its byline together.

<article>
  <hgroup>
    <h2>Understanding the Event Loop</h2>
    <p>A deep dive into how JavaScript handles async code</p>
  </hgroup>
  <p>Article content...</p>
</article>

Best practices

  • Use hgroup specifically to pair a heading with a subtitle or tagline, not as a general wrapper for multiple headings
  • Keep the subtitle content as a paragraph or similar, not another heading level
  • Do not overuse hgroup — most headings do not need a subtitle wrapper
  • Test how assistive technology in your target browsers handles hgroup, since support has evolved over time

At a glance

Purpose
Structure and meaning for web content
File extension
.html · .htm
Runs in
Web browsers
Usually used with
CSS and JavaScript

Specifications & further reading

Related HTML documentation