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
Sergey Pomaraiko5,572 Points
why we use so many div tags and never section tag?
In this example there is no one section tas. In which case we can use it?
Very good question. Most of the people don't write HTML how it should be written. Section and article tags are semantic elements and they should be used in proper way. So basically div tag should only be used when it's appropriate, when there's is really need for div because any other element doesn't work. Definitely div should not be used in example <div class="nav"><ul><li></li></ul></div> - most of the people write something like this but why use div with class nav when you have <nav> element. You should check out the documentation on using article, section, main, nav, header and footer.
I don't know about HTML Basics course but you should use <div> only when it's appropriate, that means only when anything else doesn't make sense. Maybe it's almost impossible to write everything 100% as it should be but you can get closer to that. Just read MDN page about HTML and semantic elements and you will get a much better understanding. People often use <div> because they are lazy to learn what is the purpose of semantic elements and why is <header> much better than <div class="header">. Most of the people don't know what looks like a well-structured document, it's not hard it just looks for a little more extra effort to learn those practices. <article>
- The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. <section>
- represents a standalone section — which doesn't have a more specific semantic element to represent it — contained within an HTML document. Typically, but not always, sections have a heading.