10

It's my understanding (based from this chapter of Dive into HTML5: http://goo.gl/9zliD) that it can be considered semantically appropriate to use H1 tags in multiple areas of the page, as a method of setting the most important title for that particular content.

If I'm using this methodology, and I have a SECTION which I've assigned an H1 of 'Articles', should I use H1 or H2 to define the titles for ARTICLEs in that SECTION? This is a bit confusing to me as the article titles are the most important heading for their ARTICLE, but are also 'children' of the SECTION's title.

Example code:

<section class="article-list">
  <header>
    <h1>Articles</h1>
  </header>

  <article>
    <header>
      <h2>Article Title</h2>
      <time datetime="201-02-01">Today</time>
    </header>
    <p>Article text...</p>
  </article>

  <article>
    <header>
      <h2>Article Title</h2>
      <time datetime="2011-01-31">Yesterday</time>
    </header>
    <p>Article text...</p>
  </article>

  <article>
    <header>
      <h2>Article Title</h2>
      <time datetime="2011-01-30">The Day Before Yesterday</time>
    </header>
    <p>Article text...</p>
  </article>
</section>
6
  • I have heard mixed reviews of the Dive into... series. From what I understand it may not be the best reference.
    – erik
    Feb 1, 2011 at 20:23
  • 4
    @espais: Where did you hear these reviews? Do you have a link to one of them negative ones? Feb 2, 2011 at 4:03
  • @Lèse: I can't place it to anything more than heresay at this point. I'm pretty sure I saw it on one of the SE sites in the past...but right now I have no sources.
    – erik
    Feb 2, 2011 at 16:16
  • 1
    @espais bizarre, since all of the references I can find to it in Webmasters and SO are not only positive, but typically highly upvoted. stackoverflow.com/search?q=%22dive+into+html5%22 , webmasters.stackexchange.com/search?q=%22dive+into+html5%22
    – Yahel
    Feb 2, 2011 at 21:19
  • @Lèse: yea, since i really can't back up my comment then i'll respectfully withdraw it
    – erik
    Feb 3, 2011 at 16:25

4 Answers 4

7

Pilgrim isn't alone in contending this.

According to Jeremy Keith's HTML5 for Web Designers, you can use multiple <h1>s in a document without ruining the document summary, as long as they are nested within discrete semantic sectional tags.

Quoting directly from the eBook (which I purchased from iBooks)

So far, the new sectioning content isn’t giving us much more than what we could do with previous versions of HTML. Here’s the kicker: In HTML5, each piece of sectioning content has its own self-contained outline. That means you don’t have to keep track of what heading level you should be using—you can just start from h1 each time:

<h1>An Event Apart</h1> 
    <section>
        <header>
            <h1>Cities</h1>
        </header>
         <p>Join us in these cities in 2010.</p> 
        <section>
            <header>
                <h1>Seattle</h1>
            </header>
            <p>Follow the yellow brick road.</p> 
       </section>
        <section>
            <header>
                <h1>Boston</h1>
            </header>
            <p>That’s Beantown to its friends.</p> 
        </section> 
        <section>
             <header>
                   <h1>Minneapolis</h1>
             </header>
             <p>It's so <em>nice</em>.</p> 
         </section>
     </section> 
     <small>Accommodation not provided.</small>

(Sample code also from the book, page 73)

1
  • @Matt no problem. This isn't to say that there might not be issues with doing this. Two come to mind. First, this can be a bit weird for CSS, but its managable. But more importantly, this could be hazardous for SEO, as there's a fairly well established Conventional Wisdom that one should only have one <h1> on your page, and that anything else dilutes the ability of crawlers to decipher your site. But I'm no SEO guru, so I can't comment on that.
    – Yahel
    Feb 2, 2011 at 21:16
2

I would tend to agree with Mark Pilgrim's interpretation. If you're enclosing your article inside of an article element, then you can start over again with an h1 heading for the article.

In the HTML5 spec, articles are supposed to be treated as an independent, self-contained part of the page. You should be able to transplant the article element as is into another page without re-formatting the headings.

If article headings had to be a continuation of the document heading hierarchy, then when you drop the article directly under a body tag, you'd need to go to h1, but if you dropped it under nested sections, you'd have to change it to h3/h4/h5/etc., depending on where you place it.

In fact, any time you create a new section or article, you should go back to h1, as the following are identical:

<article>
  <h1>Meta Data</h1>
    <h2>Data Warehousing</h2>
    <h2>On the Web</h2>
      <h3>Dublin Core</h3>
      <h3>XFN</h3>
      <h3>Microformats</h3>
      <h3>RDFa</h3>
</article>

and:

<article>
  <h1>Meta Data</h1>
  <section>
    <h1>Data Warehousing</h1>
  </section>
  <section>
    <h1>On the Web</h1>
    <section>
      <h1>Dublin Core</h1>
    </section>
    <section>
      <h1>XFN</h1>
    </section>
    <section>
      <h1>Microformats</h1>
    </section>
    <section>
      <h1>RDFa</h1>
    </section>
  </section>
</article>

As a side note, if your header is just a heading element (e.g. h1) and nothing else, then you don't need to wrap it in a header element.

2
  • Thanks Lèse. Could you provide a reference for your note about appropriate use of the 'header' element? I'm interested to read more about this.
    – Matt
    Feb 2, 2011 at 13:38
  • @Matt: I'm mostly basing this on the wording of the HTML5 spec, which calls header "a group of introductory or navigational aids". This and the fact that the specs for h1-h6 don't require them to be nested in a header (and include many examples of them used directly in the section they're a part of) suggests to me that it's unnecessary. This sentiment is echoed by both Oli Studholme and Remy Sharp of HTML5 Doctor. Feb 4, 2011 at 17:46
0

While the article titles of your page are important, generally the top level heading of the page defines the content of the page. Sometimes it's the name of the article, and sometimes, as you show is the title of a listing of articles.

<h1>My Very Interesting Articles</h1>

This heading defines the whole page as 'interesting articles'. Then each article is listed but have a lesser heading level.

-1

The official w3schools answer to the use of heading tags on a page is as follows: H1 headings should be used as main headings, followed by H2 headings, then the less important H3 headings, and so on.

8
  • 5
    There's actually nothing "official" about W3Schools. It's a misleading name, since they're not affiliated with or endorsed by the W3C in any way. Feb 2, 2011 at 3:55
  • indeed, see w3fools.com for a detailed take down of how terrible W3Schools is.
    – Yahel
    Feb 2, 2011 at 4:43
  • I thought this q&a site would have a few more constructive users. You guys seem a bit haughty. Feb 2, 2011 at 5:11
  • 2
    It has nothing to do with haughtiness, and nothing to do with a desire to be mean, and everything to do with a desire to see misinformation like this quashed. Too many people think w3schools is an authoritative, accurate source, and its extremely damaging to the quality of web development. The whole point of the stackexchange sites is to provide accurate, quality answers, and to push down and correct answers that are inaccurate, incorrect, or misleading.
    – Yahel
    Feb 2, 2011 at 12:27
  • 1
    Actually, your answer completely ignored my question and answered a question which was not asked. My question clearly stated 'If I'm using this methodology...' This portion was even in bold to ensure the question was clear. I would assume this is the most likely reason your response was voted down.
    – Matt
    Feb 2, 2011 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.