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 trialJohanna Svensson
1,998 PointsCould you have two <h1> per page? This is what she does in the video.
I thought you could only have one <h1> per page/document. Can someone please explain how it is possible to have one <h1> in the header and one in the specific-for-page content, as in the video?
3 Answers
Steven Parker
231,236 PointsHaving only one is a suggestion and not a technical limit. According to MDN:
Using more than one will not result in an error, but using only one is seen as a best practice.
This particular code might be considered an exception to the "best practice" suggestion since the first h1 (in the header) is modified by the CSS to not display the text (because font-size set to 0) and just show a background image insead. Perhaps the video explains why this was done instead of just using an img tag for the logo, which might have been less confusing. But the visual end result is the same.
Johanna Svensson
1,998 PointsYou have to look in one of the previous videos in this serie ("Including the header"). There you can clearly see that she has a <h1> in the header.php as well.
If you use a h1 in header.php, then to follow best practice, you cannot have another <h1> in the specific-for-page contents, right? But then your <h1> will be the same for all you pages and that's not what you want. What would be the solution? Skip the <h1> in the header?
Johanna Svensson
1,998 PointsOk, thank you for discussing this topic!
Steven Parker
231,236 PointsJohanna Svensson — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!
Steven Parker
231,236 PointsSteven Parker
231,236 PointsIf an h1 was being used in the normal way in the header, the standard practice would be to use h2's later in the document instead of additional h1's. But as I said, it's not technically prohibited..