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.

PHP Build a Basic PHP Website (2018) Building a Media Library in PHP Including the Header

Rasbin Rijal
Rasbin Rijal
Courses Plus Student 10,863 Points

[ SOLVED ]Including a header file

In the video shown, When moving the header files from index.php to header.php, the opening div of content is also copied in last line. Why should we copy the opening div at last line? Is it the strict rule?

<div class = "content">

2 Answers

If your going to have all of your content wrapped in a DIV on every page, than it's saving you two lines of code per page; " div id='content' " and the closing tag. I think the div in the header is irrelevant to what they are teaching you, the purpose of that particular video/tutorial is to show you how to include a header (and other .php pages) into your website.

You'll quickly learn that when you code a few websites, that every website is different, code format will very rarely be the same as the last.

Its not a strict rule though it helps when you have multiple content pages so that you don't forget to add the content containers div to one of your pages.