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

What are Divs

Hi…I'm not sure what the purpose of the div tag is. What does it do? Why was it put around so much stuff in the website?

5 Answers

Hi Robin

Div is short for "divider." A divider or div is used whenever you want to put a new content area in. You see so many div tags in website as there are many different areas to divide and individually style. Divs can assigned style values via div id or div class which will call on your CSS for styling purposes.

There's some great information in the HTML and CSS Deep Dives. Check them out!

Tyler van der Hoeven
Tyler van der Hoeven
11,863 Points

Think of it as a simple box. An empty, lonely, plain box. Once we have that though we can fill it with content.. text, images, cat gifs, etc.. You can also add selectors to that box like classes or ids which you can grab ahold of in CSS to color, size and space it on a webpage. Div is not the only box.. everything in HTML is some type of box. h1, p, article, form, input.. there are tons.. but each box has a purpose and intended use. Some have preset styles, others have limitations or some other semantic meaning for SEO. Div is often used because its pretty basic and empty, which makes it the perfect candidate for styling however you see fit. A webpage is really just a neatly organized stack of boxes within boxes.

Hi Robin,

A div tag defines a division or section within a html document, it is also considered a generic block level element. The div's give you the ability to customize sections of your site, therefore the reason you see so many is due to different styles being attributed to sections of your website as they are divided up for this reason.

Sukhraj Grewal
Sukhraj Grewal
10,554 Points

The div tag defines a division or a section in an HTML document. The div tag is used to group block-elements to format them with CSS.

Thanks everyone for all the great answers.