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 How to Make a Website HTML First Create the Content Containers

Reinart Bacalso
Reinart Bacalso
5,001 Points

What's the difference of <div> tags and <section> tags and when to use which?

In this video, if I were told to make the site structure, i'd use <div> tags all the way. What's with the <header> and <footer> tags?

http://stackoverflow.com/questions/7183132/how-to-correctly-use-section-tag-in-html5

stack overflow has a good answer

generally, use a div tag whenever you want to style an element

the W3 spec states

'A general rule is that the section element is appropriate only if the element's contents would be listed explicitly in the document's outline.'

so I guess section is more of a semantic element than anything else, you just use it to indicate where different parts of your document start and end

2 Answers

well, you shouldn't look at it that way

semantics is very important, for one, it makes your website more accessible and user friendly to people with accessibility issues, as it makes your site easier for screen readers to read

also google crawlers like semantics as well, so the better your code is structured semantically, the higher your website will appear in search engine results

Reinart Bacalso
Reinart Bacalso
5,001 Points

I see. Thanks for clearing stuff up!

Stephen Bone
Stephen Bone
12,359 Points

Hi Reinart

Don't know if this will help or just add to the confusion (and following a search on Google you're not alone) but this is the answer I've found. With a link to the full article below.

"you use the SECTION element to define semantically discrete portions of the content, and you use the DIV element as hooks for CSS and JavaScript as well as defining layout that does not have a semantic meaning."

http://webdesign.about.com/od/html5tags/fl/div-vs-section.htm

Hope it helps!

Reinart Bacalso
Reinart Bacalso
5,001 Points

Oh so it doesn't really have any functionality, it's just there to make the html easier to read. Did I get that right?