W3C validation says h1 in article is invalid
Asked Answered
A

2

16

I'm running my website through the W3C validation service. I'm getting an error message for the following HTML:

<section class="about">
  <article>
    <header>
    <h1>Mission</h1>
    </header>
    <div class="content">
      <p>bla bla bla</p>
    </div>
    <aside>
      <img src='/images/logo-hse-250x250.png' />
    </aside>
  </article>
</section>

The W3C validation error is:

Consider using the h1 element as a top-level heading only (all h1 elements are treated as top-level headings by many screen readers and other tools).

<h1>Mission</h1>

I thought with HTML5, it was allowed to use more than one h1 tag on a page. And that h1 tags could be used inside article elements.

Does anyone have a clue why W3C isn't validating this HTML?

Accrue answered 23/9, 2014 at 13:13 Comment(3)
It doesn't say "invalid", it says "consider using...", and it's not an error, it's a warning. After I add an alt attribute to the img, the checker reports "The uploaded document was successfully checked as HTML5."Flyblown
Side note: If this section doesn’t contain anything else besides the article, it’s likely that this section shouldn’t be there.Connally
thanks to all for the feedback. @unor, yes, I was thinking that too, so I removed all unecessary section elements. Then of course I had some layout fixing to do, but that's solved now.Accrue
C
20

It is valid to use h1 there.

The W3C Markup Validator does report a warning, not an error. You can ignore warnings if you like to.

The HTML5 spec "encourages" authors to use "headings of the appropriate rank" instead of h1 everywhere. But an encouragement is not a normative requirement.

Connally answered 24/9, 2014 at 12:41 Comment(1)
Related answer: Possible reasons for using h1 everywhereConnally
J
-4

<h1> Tag must be used as top-level heading, i.e, as page heading/tittle. Here you are the W3C Reference

That's is because SEO purposes; ensuring content is formatted in the best way possible to aid search engine indexing; and because technical correctness; ensuring that markup is written in accordance with the appropriate W3C spec.

Depending on the strucutre of your page, you can use more than one perhaps, but it's better not tu use more than one <h1> tag

enter image description here

Jurado answered 23/9, 2014 at 13:42 Comment(1)
The "W3C reference" you give is eight years old! The "W3C spec" you refer to says nothing about the usage of H1, just its syntax. With regard to SEO, you need to refresh your knowledge of the subject. Search engines have been successfully indexing pages with no H1 tags and multiple H1 tags for years now, thank you very much, they don't need much help in the markup department these days. In fact, they may ignore markup in some cases to avoid keyword spamming etc. Finally, I'm afraid your understanding of the new semantics of H1 under HTML5 is sorely lacking. I'd suggest you bone up on that.Flyblown

© 2022 - 2024 — McMap. All rights reserved.