Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Basics Structuring Your Content Using Multiple <header> and <footer> Elements

ian izaguirre
ian izaguirre
3,220 Points

Wondering if we should really add a "header" around every "article" tags heading ?

I am asking this question because I came across this "Common HTML5 Mistakes" Post , and found "Overuse of header"

LINK: http://html5doctor.com/avoiding-common-html5-mistakes/

Quote:

"If your <header> element only contains a single heading element, leave out the <header>. The <article> ensures that the heading will be shown in the document outline, and because the <header> doesn’t contain multiple elements (as the definition describes), why write code when you don’t need to? ... "

2 Answers

Steven Parker
Steven Parker
229,786 Points

The video does suggest using the header around multiple elements: "So, let's wrap both of our articles titles with header tags and we'll also include an author name."

ian izaguirre
ian izaguirre
3,220 Points

So your supposed to use a <header> if you write this:

<article>
<header>
<h1> This is a header </h1>
<p> Some date </p>
</header>
</article>

But it would be wrong in this situation? :

<article>
<header>
<h1> This is a header </h1>
</header>
</article>
Steven Parker
Steven Parker
229,786 Points

"Wrong" might be a bit strong, but it would certainly be a bit excessive, and it would violate the guidelines proposed by the post you quoted.

But it still might be useful if you were trying to be consistent about document structure and always include a header in an article.

Shayne Laufenberg
Shayne Laufenberg
4,213 Points

So if we take a look at Semantic Elements there is only 1 real reason why someone would use these HTML5 tags over using straight up div elements like we have in HTML4 and it all comes down to how well you wanna optimize your website for search engines. I'll talk about the header tag specifically to give you a little insight about these tags. The header tag in general in my eyes shouldn't be used more than once but it can be if you'd like to use it that way. The header can define ether a section or the header of your document, using more than 1 shouldn't confuse or hurt anything at all however HTML5 does have a <section> tag as well to help centralize your data. Think of it as a way of communicating with the search engine without needing to directly tell it what to look for.

So that article is wrong in the sense that using header multiple times is really bad, since it can be defined in two different ways but you should separate your articles using the article tag and then when you define titles of articles it looks for <h> tags like <h1>,<h2> etc.. when you use header really it can be used for a page header or an article header ether or is fine just remember you are making your site more search friendly that is its purpose.

I'd take a look at this it will give you more insight on the subject of the header tags specifically https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header