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

CSS How to Make a Website CSS: Cascading Style Sheets Use ID Selectors

ROSEMARY SMITH
ROSEMARY SMITH
1,041 Points

<div id="wrapper">

Hi, Why don't I have to update the closing </div> to the new name "wrapper"

3 Answers

Guy Noda-Bailey
Guy Noda-Bailey
18,837 Points

Hey there Rosemary,

The web browsers keep track of which div you will be closing when you close a div with the </div> closing tag.

Because of the way html elements have to be 'nested' there is no ambiguity about which element you are closing, ie if you have to close all elements inside an element before closing the element.

Sometimes when I found it difficult to keep track of which element was inside of which I would comment the closing tags to help me keep track.

<div id="mainDiv">
  <div id="innerDiv">
  </div>  <!-- closing innerDiv -->
</div> <!-- closing mainDiv -->

but the browser doesn't need this to keep track.

ROSEMARY SMITH
ROSEMARY SMITH
1,041 Points

What can those browsers not do! Thanks so much for your answer and for your solution for keeping track. Appreciate it, so fast too!

Guy Noda-Bailey
Guy Noda-Bailey
18,837 Points

Browsers are so much smarter than us (in some ways).

Glad I could help.

Guy Noda-Bailey
Guy Noda-Bailey
18,837 Points

If you want a rant about what those browsers cannot do, just ask a web developer how much they love Internet Explorer. :)