Is it alright to use multiple h1 tags on the same page, but style them differently?

Viewed 31857

I have a webpage that I use h1 tags multiple times within various DIVs and I style h1 for each div to be the appropriate size.

For example...

#content h1 {
  font-size:22px;
}

#left-nav h1 {
  font-size:14px;
}

#content .recent-news h1 {
  font-size:16px;
}

Is this alright?

15 Answers

Just remember that your h1s are used to indicate context, not layout. So, there's nothing inherently wrong with having several on a page.

In this specific example, you need to decide if your left-nav h1s have the same contextual importance as your content h1s and your recent-news h1s. If a clear hierarchy exists in your mind, use your header tags to demonstrate it.

In my opinion, you don't need to worry, its ok to do it like this.

H1 designates part of your contents to be a first level heading. So if you have a first level heading in your navigation div (e.g. <H1>Navigation Menu</H1>), of course that should be #nav h1.

If you should have several H1s within your contents depends: If you have a blog and every entry has its own heading, those would be H1s. However, if your blog itself has a heading (e.g. <H1>My Blog!</H1>), the blog entry heading should be an H2.

But that is only theory. Go for what is readable, semantic markup. You can best decide on that by looking at your html and asking yourself: 'Is it readable? Would the readability improve if I did it the other way?' The answer will vary from project to project.

In general, you should only have one h1 per page, and that h1 should succintly represent the content on that page. As long as you are willing to style with CSS, find out which level of headings (h2, h3, h4, etc) that properly represent the headings you want to use, and then style them instead.

Semantically, I prefer using one h1 on the page, mainly for the title of the page. It probably doesn't matter too much with SEO, and with the way html is going with HTML5, the generic header tag will make it much simpler and this argument obsolete.

You can but you shouldn't have multiple H1s anyway.

Quoting A11yproject's Accessible Heading structure (How-Tos article link)

Having multiple h1s on a web page is bad practice, for accessibility and for SEO. It creates a flat and meaningless structure. But, it's not a WCAG 2 AA violation. The long answer involves a short history lesson.

Using multiple h1s was proposed with the introduction of the HTML Document Outline in HTML5. Each section in the outline could contain an H1. But here's the snag: The Document outline was never adapted by browsers or assistive technology. Therefore the support for multiple h1s was dropped in HTML5.1

I don't like the idea of multiple H1s. H1 is the top level, most important heading and the page will basically be about that topic. If you have an equally important second topic, don't put it in another H1 tag, just put it in another page. It deserves that, right?

In trying to answer the same question I posted this question which may have some useful information. My concern with using the same H1, H2, H3 in differnt places is that unless you ALWAYS specify a 'parent' style as you did in your example* - then you can run into problems.

Dilemma in deciding how to create CSS for H1, H2, H3 etc.

* thats to say you never define 'h1' by itself

I try to have only one H1 on the page and have it almost but slightly re-arranged from the content of the title tag / H1 is the the main idea of an individual page every thing else should be an h2 tag and Lower....

With the adoption of HTML5, several H1's is perfectly fine if it's reasonable. It was fine, IIRC, also in HTML4 but it I never saw it used unless the page(s) were quite spammy.

One example where multiple H1's is applicable, is a list of articles with title, excerpt and href that links to the full thing:

<header>
    <h1>Articles</h1>
    <h2>About fish</h2>
    <p>Some intro text</p>
</header>

<section id="articles">
    <article>
        <h1>Title</h1>
        <blockquote class="excerpt">
            Excerpt here
        </blockquote>
        <a href="/whatevs">Read more</a>
    </article>
    
    <article>
        <h1>Title</h1>
        <blockquote class="excerpt">
            Excerpt here
        </blockquote>
        <a href="/whatevs">Read more</a>
    </article>

</section>

This is semantically just as it should be and thus, also good in terms of SEO. In fact, I would argue that this is better than having H2's for the articles, as the article itself is not a sub title to "Articles about fish", but I guess that could be argued against, as well.

Concerning SEO and h1 multple, although Google has a dominant position, it is interesting to note that Bing Webmaster Tools raises a hight severity SEO issue so if you are interested in optimizing for multiple search engines, it may be relevant to limit H1 tags to 1. Below example from a site I work on:

enter image description here

It's best to have 1 H1 per page, as it simplifies and tells Google your main topic.

Any subheadings should be H2's, and subheadings below those should follow in hierarchal order:

H1 H2 H3 H4 H5, and so on.

You want to maintain this exact order. If you start a new section, start with H2 and maintain the same order.

Related