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

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

Rasbin Rijal
Rasbin Rijal
Courses Plus Student 10,864 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.