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 TAG QUESTION (HTML)

Can someone please explain to me, why there front end web developers use soo many div tags in html when creating a front end website.

2 Answers

Steven Parker
Steven Parker
229,608 Points

The <div> tag is a generic container so it's good for grouping elements (and/or other containers). Some developers may use them over-liberally "just in case" they want to apply styling with CSS or add some JavaScript functionality to a certain group at a later time.

Of course, "best practice" would be to remove unnecessary containers from the final design, but it's easy to overlook this since they don't impact the appearance of the page if left in.

The <div> tag defines a division or a section in an HTML document.

The <div> element is often used as a container for other HTML elements to style them with CSS or to perform certain tasks with JavaScript.