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

dijanadenic
2,198 Points<div> inside of another <div>?
I just noticed in this lesson that a div has been entered into a div that wasn't closed. is that alright to do?
<div class="primary-content top-border"> <p> Lake Tahoe is one of the most breathtaking attractions located in California. It's home to a number of ski resorts, summer outdoor recreation, and tourist attractions. Snow and skiing are a significant part of the area's reputation </p> <a href="#more">Find out more</a>
!! <div class="wildlife">
<h2>Check out all the Wildlife</h2> <p> As spawning season approaches the fish acquire a humpback and protuberant jaw. After spawning they die and their carcasses provide a feast for gatherings of <a href="#">mink</a>, <a href="#">bears</a>, and <a href="#">Bald eagles</a>. </p> <a href="#">See the Wildlife</a> </div> .....
2 Answers

Jason Anders
Treehouse Moderator 145,862 PointsHey there,
Yep, it's perfectly fine. In fact, nesting
<div> tags inside of each other is very common when using them to style the page. You will often see 1 - 2 - 5 or even move all nested inside of one main div (more often than not the container
div. As you move forward in CSS and HTML courses here on Treehouse you will see this in more detailed action.
Keep Coding! :)

Jason Welsh
Treehouse Project ReviewerI couldn't tell from your question, but the above answer is very correct, however, if you are asking if it is ok to leave div elements unclosed, the answer is no. Sometimes the browser will handle that fine, and sometimes it will cause errors to occur. So make sure to close all div elements, whether or not they are nested inside another div.
Example:
<div id="container">
<div id="box">
</div> <!-- /#box-->
</div> <!--/#container-->
I find it is helpful to comment which div you are closing in the HTML