Search code examples
htmlsemantic-markup

Heading Tag within a Header Element


I just finished reading the HTML5 Developer's Cookbook and have a question. I've read the specs, but now I can't find the reference to what I'm trying to figure out.

In the HTML5 Developer's Cookbook, one of the code examples; figure 1.9, listing 1.10 - is:

// ...
<header>
    <h1>Jase is awesome</h1>
</header>
// ...

Now, I understand when and where to use the header element, and I also understand when and where to use the h1 tag. But, my question is, Should, or must we always or only use the h1 tag inside a header element, as shown in the above example?


Solution

  • You may use a <h1> tag anywhere in the document where it's allowed. If it so happens that you're using it semantically in the <header> element, go right ahead. If your main title of the page is not within the <header> element, don't use it there.

    In short, yes, if it fits. Use your best judgment.