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

Header and Footer.php

So i'm working on the php application, and i noticed that on the footer for example we start to copy the code on a closing div tag instead of copying below that tag. Here's the example to make it clearer:

</div>

    <div class="footer">

        <div class="wrapper">

            <ul>        
                <li><a href="http://twitter.com">Twitter</a></li>
                <li><a href="https://www.facebook.com">Facebook</a></li>
            </ul>

            <p>&copy;<?php echo date('Y'); ?> Shirts 4 Mike</p>

        </div>

    </div>





        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.2.min.js"><\/script>')</script>
        <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

        <script src="js/plugins.js"></script>
        <script src="js/main.js"></script>

        <!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
        <script>
            (function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
            function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
            e=o.createElement(i);r=o.getElementsByTagName(i)[0];
            e.src='//www.google-analytics.com/analytics.js';
            r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
            ga('create','UA-XXXXX-X');ga('send','pageview');
        </script>
    </body>
</html>

So as you can see, the 1st line of the footer.php is a closing div. So my question is, why are we including this closing div on our footer file instead of just including what's below that closing tag,as in the actual footer itself?

Ty in advance...

2 Answers

The way I see it is that you're always going to have that closing div tag on all of the pages (at least in this project). In other projects that might not be true. However the footer - and for that matter the header should include any and all code that repeats throughout the project. It's not that the closing div had to be included but it is the lowest point in the code that is seen (or included) on all pages. So in other words, everything above that point and below the header changes from page to page. The point at which this happens will vary from project to project.

Ah ok, that makes sense. So if the element immediately above the footer is common to all the pages, like this closing div tag, i include it on the footer file as well.

Thx for the help.

Your welcome! I'm glad I could help.