Contains introductory content, often includes hgroup. Learn more →
<hgroup> ElementThe <hgroup> element groups a heading element (h1-h6) with one or more subheadings, subtitles, alternative titles, or taglines. It prevents subheadings from creating their own sections in the document outline, making it clear that they are subordinate to the main heading.
<hgroup> <h1>Main Heading</h1> <p>Subtitle or tagline</p></hgroup>The <hgroup> element has no element-specific attributes.
This element supports all global attributes.
A blog post or article with a main title and descriptive subtitle:
A page or section header with a tagline:
Product pages with titles and descriptive subtitles:
Headings with alternative titles or translations:
Event pages with date and location information:
Hero sections with main heading and supporting text:
Book chapters with titles and subtitles:
The <hgroup> element should contain:
<p> elements - For subtitles, taglines, or alternative titles<!-- Valid: h1 with p elements --><hgroup> <h1>Main Title</h1> <p>Subtitle</p> <p>Additional tagline</p></hgroup>
<!-- Valid: Any heading level --><hgroup> <h2>Section Title</h2> <p>Section subtitle</p></hgroup>
<!-- Invalid: Multiple heading elements --><hgroup> <h1>Title</h1> <h2>Subtitle</h2><!-- Should be <p> instead --></hgroup>
<!-- Invalid: Non-heading, non-p elements --><hgroup> <h1>Title</h1> <span>Subtitle</span><!-- Should be <p> --></hgroup>Only use <hgroup> when you have a genuine subtitle or tagline:
<!-- Good: Genuine subtitle --><hgroup> <h1>Understanding CSS Grid</h1> <p>A practical guide to two-dimensional layouts</p></hgroup>
<!-- Avoid: Misusing for other content --><hgroup> <h1>Article Title</h1> <p>By Author Name</p><!-- This is metadata, not a subtitle --></hgroup>
<!-- Better: Separate metadata --><h1>Article Title</h1><p class="byline">By Author Name</p>Use only one heading element per <hgroup>:
<!-- Wrong: Multiple heading elements --><hgroup> <h1>Main Title</h1> <h2>Subtitle</h2></hgroup>
<!-- Correct: h1 with p --><hgroup> <h1>Main Title</h1> <p>Subtitle</p></hgroup>Style the paragraph elements to look like subtitles:
<hgroup> <h1 style="font-size: 2.5rem; margin: 0;">Main Title</h1> <p style="font-size: 1.25rem; margin: 0.5rem 0 0 0; color: #666; font-weight: normal;"> This is styled as a subtitle </p></hgroup>Combine <hgroup> with other semantic elements:
<article> <header> <hgroup> <h1>Article Title</h1> <p>Article subtitle</p> </hgroup> <p class="byline">By Author | Date</p> </header>
<p>Article content...</p></article>The <hgroup> element affects the document outline by treating the entire group as a single heading:
<!-- Without hgroup: Two separate headings in outline --><h1>Main Title</h1><h2>Subtitle</h2>
<!-- With hgroup: Single heading in outline --><hgroup> <h1>Main Title</h1> <p>Subtitle</p></hgroup>Screen readers typically announce the heading element and may treat paragraph elements as regular text:
<!-- Screen reader might announce: "Heading level 1: Main Title. Subtitle text." --><hgroup> <h1>Main Title</h1> <p>Subtitle text</p></hgroup>The <hgroup> element has no implicit ARIA role. The heading inside maintains its role:
<hgroup> <h1>Title</h1><!-- role="heading" aria-level="1" --> <p>Subtitle</p><!-- Regular text --></hgroup>| Browser | Version |
|---|---|
| Chrome | 5+ |
| Firefox | 4+ |
| Safari | 5+ |
| Edge | All versions |
| IE | 9+ |
The <hgroup> element has an interesting history:
Contains introductory content, often includes hgroup. Learn more →
-
Heading elements used within hgroup. Learn more →
Self-contained content that may have hgroup. Learn more →
Thematic sections that may have hgroup. Learn more →
<!-- Wrong: Metadata in hgroup --><hgroup> <h1>Article Title</h1> <p>By Jane Doe | March 15, 2025</p></hgroup>
<!-- Correct: Separate metadata --><hgroup> <h1>Article Title</h1> <p>A comprehensive guide</p></hgroup><p class="byline">By Jane Doe | March 15, 2025</p><!-- Wrong: Multiple headings --><hgroup> <h1>Main Title</h1> <h2>Subtitle</h2> <h3>Sub-subtitle</h3></hgroup>
<!-- Correct: One heading with p elements --><hgroup> <h1>Main Title</h1> <p>Subtitle</p> <p>Sub-subtitle</p></hgroup><!-- Wrong: Using hgroup when not needed --><hgroup> <h1>Simple Title</h1></hgroup>
<!-- Correct: Just use the heading --><h1>Simple Title</h1>
<!-- Use hgroup only when you have subtitles --><hgroup> <h1>Title</h1> <p>With a subtitle</p></hgroup><!-- Wrong: Invalid children --><hgroup> <h1>Title</h1> <span class="subtitle">Subtitle</span> <div>Extra content</div></hgroup>
<!-- Correct: Only h1-h6 and p --><hgroup> <h1>Title</h1> <p>Subtitle</p></hgroup>