How to use <section> and <article> tags in HTML5?

I'm just confused how to use tags <article>and <section>in HTML5.

I referenced the lot on Google, as well as on the Stack Overflow website.

In doing so, I found HTML5 pages with elements <section>containing elements <article>and <article>elements containing <sections>elements.

I also found pages with elements <section>containing elements <section>and <article>elements containing elements <article>.

What is the exact use of these tags?

0
source share
1 answer

It depends on your content.

, section, article ( 1), article section ( 2), article section article ( 3).

, ? :

  • , section.
  • nav. , nav, else:
  • aside. , aside, else:
  • article. , article, else:
  • section.

1:

<section>
  <h1>Recent blog posts</h1>

  <article>
    <h2>Blog post 1</h2>
  </article>

  <article>
    <h2>Blog post 2</h2>
  </article>

</section>

2:

<article>
  <h2>Blog post 1</h2>

  <section>
    <h3>So, this is what happened</h3>
  </section>

  <section>
    <h3>What the others said</h3>
  </section>

</article>

3:

<article>
  <h2>Blog post 2</h2>

  <section>
    <h3>Comments</h3>

    <article>
      <p>First!</p>
    </article> 

    <article>
      <p>First! <ins>Edit: Damn, second :(</ins></p>
    </article>        

  </section>

</article>
+8

All Articles