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

Jamie Belden
Jamie Belden
5,145 Points

<article> versus <section>

I am confused right now on the differences between the article tag and the section tag. They are both part of Semantic HTML. Which breaks up into three main categories to organize content: <header>, <section>, and <footer>. But one of the classes I just took ("Marking up a Blog Post" by Guil Hernandez) had me organize the code with a header and footer but instead of section tags in the middle, we just had article tags. So can they be used interchangeably? Or are article tags a smaller entity and should placed within a section tag?

2 Answers

Hi Jamie,

A good blog post by Matt West How to Use The HTML5 Sectioning Elements explains this.

At a very basic level I would think of this in the following way:

  • Sections represent a generic section of a document (in a way, similar to div tags but with more semantic meaning)
  • Articles represent a self-contained composition on a page such as a blog post or news article.
Jamie Belden
Jamie Belden
5,145 Points

Thank you Ross! So would it be incorrect to nest article tags within section tags? (Example below)

<body> <section> <article> </article> <article> </article> </section> </body>

No, it would not be wrong.

You may have a section such as breaking news. Inside that section you may want to nest multiple articles on the different news headlines for the day.

Jamie Belden
Jamie Belden
5,145 Points

That makes perfect sense, thank you very much