I just confused how to use <article>
and <section>
tags in HTML5.
I referenced lot in Google and also in Stack Overflow website.
On that, I found HTML5 pages with <section>
elements containing <article>
elements, and <article>
elements containing <sections>
elements.
I also found pages with <section>
elements containing <section>
elements, and <article>
elements containing <article>
elements.
What is the exact use of these tags?
It depends on your content.
For example, a list of recent blog posts could be a
section
containing severalarticle
(example 1), a complex blog post could be anarticle
with severalsection
(example 2), a blog post with comments could be anarticle
with asection
and severalarticle
(example 3).How to decide when to use which? Easy:
section
.nav
. If yes, go withnav
, else:aside
. If yes, go withaside
, else:article
. If yes, go witharticle
, else:section
.Example 1: A list of blog posts
Example 2: A complex blog post
Example 3: A blog post with comments