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

cynthia daou
cynthia daou
406 Points

why didn't he use <article> element instead of <section> ?

what is the main difference between the article, the section,and the div elements ?

2 Answers

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Hi cynthia, the <article> tag is what is used to represent self-contained pieces of content. The <section> tag is what is used to group related content together. Think of it as a container. The <div> tag is a generic container, similar to the <section> element. However, the key difference between the two is that the <div> element has no semantic meaning whats'o'ever and should be used sparingly when there is no other HTML5 tag that could be used to represent that piece of content.

Both the <article> and <section> tag are part of the latest HTML5 semantic markup tags. They provide semantic meaning to your content, unlike the <div> element.

Here is a good resource on semantic markup tags.

Kornelia Surmann
Kornelia Surmann
1,273 Points

Interesting. In the numerous html workspaces I've seen (working through CSS right now), the <div> tag is used several times in one html document. Are you saying that if <article> or <p> or <section> does not apply to use <div>? I am confused as to the "sparingly" response. Sparingly for me would be 1-2 times in a document and not the 3+ times I've seen.

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Kornelia Surmann I have as well, and that is probably due to the course being of old material (not the CSS). What I mean by sparingly, is that there are better and more suitable tags to approach when structuring your HTML. LIke I said, <div> has no semantic meaning and is commonly used by developers to create a wrapper/container for the overall page.

This article should give you a better insight into when to use what element to structure content on a page.

Kornelia Surmann
Kornelia Surmann
1,273 Points

Thanks! That's a great article. Love the flow chart. I am very visual and that made it super easy to understand. I'll make sure to limit my <div> tags in my personal profile page project.