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 trialJan Francírek
1,766 PointsClosing tag </div>
I do not understand why we close for example <div id="wrapper"> only with </div>.
It would have more logic to close it with </div id="wrapper"> because as Nick said, there can be more "div" so how can I avoid in future of ending the correct div.
Is it like that I can have only one div for example for header and then one div for the rest?
Thank you
Jan
2 Answers
Jan Francírek
1,766 PointsOh, I didnt notice. Thank you. I wrote it here again differently.
div id="Wrapper" - I understand this (we should´ve call it somehow to recognize it) but then when we are closing this tag it is like this
/div and that is the thing I dont understand, because It would have more logic for me to close it like this /div id="Wrapper" (close excatly the div I want)
I mean I cant then mix those divs together because I could close some div instead of another.
Is it like that I can use only one div? I have to close div1 before using div2 for example?
Thank you
J.
Saskia Lund
5,673 PointsHi Jan!
Unfortunately some of your words have been erased by the forum software. So I am not quite sure which strings you'd like better of the normal closing div tag.
<div>
I am "wrapping" or containing 1 div that contains another div.
<div>
I am nested inside another div.
<div>
I am nested inside of a div that is also nested inside of a div.
</div>
</div>
</div>
You can actually nest and place as many divs as you want in your html code. To keep the code somewhat readable and allow a better overview of which closing div Tag belongs to which opening div tag, you should use indentation in your code.
Saskia Lund
5,673 PointsSaskia Lund
5,673 PointsThink of each div element in your html code as a box.
Every box can contain anything from an image, text, to a form or/and a gallery - OR / AND other boxes (divs). like so:
Jan Francírek
1,766 PointsJan Francírek
1,766 PointsOk, now I understand it.
Danke schön Saskia :)