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 trialMamady Doumbouya
680 Pointsdiv tag
I have question on "DIV Tag". It was not covered in any prior instructions. What to do?
2 Answers
jdh
12,334 Pointsdivs are used primarily for defining "sections" or blocks in HTML and then applying CSS to those sections through classes or id's.
For instance, say we wanted to have two columns side-by-side. We can use use the div tag around our text in each column and then apply the CSS classes or IDs which position and style each column accordingly.
```html
<div class="left-column">This is our left column!</div>
<div class="right-column">This is our right column!</div>
```
If we render this in the browser its just going to show two paragraphs in-line. We then apply the css to the classes within the <div> :)
```css
.left-column { float: left; width: 50%; text-align: center; background-color: #f1f1f1; }
.right-column { float: right; width: 50%; text-align: center; background-color: #dcdcdc; }
```
Hope this helps!
James Calby
15,202 PointsWhat's the question?
Sean May
9,547 PointsI think he just wants to know what a div is. I can understand, it took me a little bit to realize that a div is just sort of an empty bucket that doesn't necessarily do anything on its own, but can make organizing your HTML and applying CSS super easy.