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 Simple PHP Application Creating the Menu and Footer Including the Footer and Adding Additional Pages

Is having the closing tag of a div in a different file than the opening tag a fragile way to construct a page?

I guess this is more of a discussion point than a question.. and I am not sure what common practice is. If a goal is to create autonomous, extracted pieces of information.... then having a div start/close in separate files creates a dependency that I would imagine would be undesirable. I would think it would be far more desirable to have a header that can be used "free and clear" as well as a footer that can be used "free and clear".

My thought is that I can see why a developer might assume that there will always be a header AND a footer, but who knows what will be needed in the future.

What do you have to say about it, internet? :)

4 Answers

Andrew Shook
Andrew Shook
31,709 Points

Ben, I think prevent opening and closing html in different files is important, but sometimes it can't be avoided. In WordPress, for example, the opening/closing html and body tags are in different file, and there really isn't anything that can be done about it.

I was wondering how WP handled that. To me, it just feels like it could be a recipe for giving your future you an immense headache.

Andrew Shook
Andrew Shook
31,709 Points

It's possible, but anyone who has worked with WordPress a few times knows that the opening and closing tags are in separate files. Still I'm not a huge fan of it.

James Barnett
James Barnett
39,199 Points

I'd say all things being equal it will be harder to maintain over time.

Hi BENJAMIN,

I can understand your concern, considering Randy/Treehouse does this in the video you are currently watching. When I first watched the video, that confused the hell out of me. I personally avoid doing this but perhaps there are times when this would be necessary.

Jeff

Rick Yentzer
Rick Yentzer
5,885 Points

One thing I do to help me maintain sanity is to add a comment after a closing or opening div that is being split into separate files. That way I can immediately tell what it is doing.

</div> <!-- end content -->