Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
221,451 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.