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 trialDeepak Sharma
1,987 PointsRegarding div element
What exactly is the purpose of div tag.The way I see it, it is use to group some group of elements.Why can we just use section to apply style
1 Answer
Michael Brown
7,431 Points<DIV> was first defined in HTML3.2 (1997) as a block element to surround other element(s) to apply left, center or right alignment. In HTML4.01 (1999) the <DIV> element received ID and CLASS attributes to identify it uniquely from other <DIV> elements, but it was still just a "grouping" element around anything for any purpose. Unlike the <H1> or <P> elements which have meaning ("Head Level 1" and "Paragraph"), the <DIV> element has no particular meaning in the document.
HTML5 brought us the new element <SECTION>, a block element that surrounds a logical group of related content, such as a chapter in a book, or a topic in an instruction manual. It typically has a heading element. HTML5 also brought us other semantic elements (elements that describe their content) such as <ARTICLE>, <NAV> and <ASIDE>.
Use <SECTION> around a group of elements when all of the content inside the <SECTION> is related, especially if the related content has a heading. But if you're just grouping some elements together in order to apply a style or other unique processing to the group, use the <DIV> element.