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

WordPress WordPress Theme Development Building Page Templates in WordPress Creating Custom Page Templates in WordPress

Missing a closing div in the video?

Hi guys, is it just me or is there suppose to be another closing div tag added that was forgotten in the video. By my calculations there should be a closing div tag for the first div with the class="small-12-columns". in the video there does not appear to be a closing div tag for this div. However with or without, my code still works.

It's not just you.
I did it on my own not watching the video and then compared results and I too had one extra closing </div> than Zac.
I double checked my code and I'm fairly sure you and I are correct on this one.

7 Answers

Richard Walton
Richard Walton
10,861 Points

This happened to me too, and I couldn't move on until I understood what was happening! Where you place the closing div is important! Zac found a div class for row was being closed too early and he removed it and didn't replace it in bottom of the page above section div, and yet still worked??! That bothered me so I closed it there as it should have been and of course it still worked!

In summation: you can leave a div open and it will still work, but if you close it (as you should) and it's in the wrong spot, it won't work. Not sure I fully understand why, but I think it's because "html5" is lenient if you don't close html tags, but closing a tag in the wrong spot confuses it (xhtml was/use to be more strict). I am coming back to building sites after years of being away ( anyone remember "GoLive, macromedia dreamweaver and hand coding table layouts"? probably not? :O)

Sorry it's as much of a question as it's an answer, but it will let me move on without losing sleep :)

Yeah, he missed one. Noticed it right away. The page will display but you will get in trouble somewhere down the line without closing it. So heres the code with the closing div tag in place:

<?php
/*
    Template Name: Left Sidebar
*/
?>

<?php get_header(); ?>

<section class="two-column row no-max pad">
    <div class="small-12 columns">
        <div class="row">
            <!-- Primary Column -->
            <div class="small-12 medium-7 medium-offset-1 medium-push-4 columns">
                <div class="primary">

                <?php if(have_posts()) : while (have_posts()) : the_post(); ?>

                  <h1><?php the_title(); ?></h1>
                  <p><?php the_content(); ?></p> 

                 <?php endwhile; else : ?>

                    <p><?php _e('Sorry, no pages found'); ?></p>

                <?php endif; ?>     

                </div>
            </div>
            <!-- Secondary Column -->
            <div class="small-12 medium-4 medium-pull-8 columns">
                <div class="secondary">
                    <h2 class="module-heading">Sidebar</h2>
                </div>
            </div>
        </div>
    </div>
</section>

<?php get_footer(); ?>
Richard Edwards
Richard Edwards
779 Points

Phew - thanks for that! It was affecting my layout. Was going crazy trying to find the missing div!

Thank you so much. I had gone through the video a couple extra times trying to figure out what I missed. Sure enough, my closing div wasn't in the right spot. You rock!

Paul Roberts
Paul Roberts
7,928 Points

Yeah I agree. It's confusing that in the video it flicks between the code and refreshed web page! I'm sure there is a < /div> missing too :)

geoffrey
geoffrey
28,736 Points

Hi there, on my side, to be sure there are no unclosed tags, I often use when necessary an unclosed tag finder such as this one. It works pretty well. Just my 2 cents :).

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

This is an interesting problem, but I would hazard to guess that when Zac removed the trailing div tag, it really did work out that all the divs tags were left matching up properly. I don't know how, but it worked out that way for me. That's why the sidebar text shows up.

My text editor isn't the most up to date, but it works for me. It's notepad++, and any text editor should IMO have a function to check HTML elements for matching elements in the document tree. I followed Zac's video and it worked as valid code. :-)

Yeah, there seems to be a missing </div>. I guess it works without it, but I had to add it in!