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

Krishnendu Banerjee
Krishnendu Banerjee
1,005 Points

What is a div

what does div mean and what does <div> </div> contain in between then.

Andreas Anastasiades
Andreas Anastasiades
2,916 Points

if you're still interested in knowing what it means, it's just "Document division" :)

2 Answers

lihaoquan
lihaoquan
12,045 Points
  1. Div is a HTML element used to group HTML elements together. It acts as a container for other html elements. Example :
<!-- This section is the header section of the page. -->
<div id="header">
   // Some html elements here.
</div>
<!-- This section is the navigational section of the page. -->
<div id="navigation">
    // Some html elements here.
</div>
  1. Contain between them means the HTML elements are in between the opening div tag, and the closing div tag. Example :
<div><!-- Opening div tag -->
    <p>This paragraph is contained in between the div</p>
</div><!-- Closing div tag -->

Adding to the other answers, div is used for applying the same CSS styling to multiple elements at once. So instead of writing the same CSS for every element (for e.g. each element in the header), instead we wrap around the header with a unique div element and use it as a selector.