Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Could 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?
Steven Parker215,372 Points
Having 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.
You 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?
Ok, thank you for discussing this topic!