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

HTML

div element

I don't understand what a div element actually is...

thanks!

3 Answers

The div element is simply a non-semantic element that the developer can use to arbitrarily divide the code into sections. It is mostly used to apply some styling to a particular section of code.

Let me know if that helps clear things up.

So it's good to put each part into a div element to make things a bit more clearer for the reader?

No if you're trying to divide up sections of code and label them to make it easy for the reader to understand, I would use comments. A div element by itself does nothing to the code that is wrapped by it.

In the code example below, the div element is applying the jumbotron class styling to the elements wrapped within. This is the primary use for a div element.

<div class="jumbotron">
    <h1>My First Bootstrap Page</h1>
    <p>Resize this responsive page to see the effect!</p> 
</div>

ah ok. i get it now. thanks a lot