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 trialAlexander Perry
Front End Web Development Techdegree Student 11,395 PointsWhy do we use a div tag to wrap instead of the main tag, when the main tag seems to be better semantic code?
We learned about semantic coding in HTML basics, and were advised to use tags that have actual meaning (and divs have none). It seems more reasonable, to me, to wrap using the main tag rather than the div tag. Is there a reason div is used instead of main?
Chris Conwell
2,268 PointsDiv is for styling. We are creating wrappers for styling purposes.
1 Answer
Steven Parker
231,275 PointsThis course appears to have been released in 2015, which is before semantic tags had wide browser acceptance, so it could why they are not used in the examples. The HTML Basics course is about 2 years newer.
Mauricio Ariza
1,731 PointsMauricio Ariza
1,731 PointsHello Alexander, What I have learned is that we should use main when we think that something is vital and that we should use it only once in our document. Analyzing different pages, I have seen that div tags are very common. I think it is because they are practical. But you're right, I think it is used a lot, and we can get lost in our HTML document. One way to use the div in a document is using'' class ''( that is a topic that you can see in CSS), naming them in different ways. In that way, we can identify them with something that has a meaning for us.