If you'd use a heading for the subtitle, a wrong document outline would be created.
<body>
<h1>John's blog</h1>
<h2 class="tagline">the best blog in the world</h2>
<div>…</div>
</body>
Here all following content (until a next h1
/h2
, if any) would be in the scope of the tagline instead of the actual blog title. Which is not what we want for a subtitle.
in HTML5
(UPDATE: The hgroup
element got removed from HTML5. See my answer to another question about how to mark up subheadings in HTML5 now.)
For HTML5, there is a new element especially for this use case: hgroup
The element is used to group a set of h1
–h6
elements when the heading has multiple levels, such as subheadings, alternative titles, or taglines.
By using hgroup
, only one of the child headings counts for the document outline.
<body>
<hgroup>
<h1>John's blog</h1>
<h2 class="tagline">the best blog in the world</h2>
</hgroup>
<div>…</div>
</body>
in HTML 4.01
There would be two ways
1) Include the subtitle in the main heading, probably separated by a colon.
<body>
<h1>John's blog: <span class="tagline">the best blog in the world</span></h1>
<div>…</div>
</body>
2) Use a p
(or if it's not a paragraph, div
) for the subtitle:
<body>
<h1>John's blog</h1>
<p class="tagline">the best blog in the world</p>
<div>…</div>
</body>
(if the immediately following content would consist of paragraphs, too, you could think of using the hr
element after the tagline)
tag as recommended by W3C for subtitles and style it using CSS. Read more here: http://www.w3.org/html/wg/drafts/html/master/common-idioms.html#common-idioms - and as @jscheel said, the hgroup has been dropped from the specification according to http://lists.w3.org/Archives/Public/public-html-admin/2013Apr/0003.html
– kexxcream Jun 07 '13 at 15:03