html – Can I use header/footer tags inside main/section tag?

Question:

I would like to know if you can, inside the <main> , or <section> element, put the <header> and <footer> tags .

For example:

<section>
   <header>topo da section</header>
      conteudo da section
   <footer>rodape da section</footer>
</section>

Where

<main>
  <header>topo da section</header>
    conteudo da tag main
  <footer>rodape da section</footer>
</main>

that way is correct??

Answer:

Yes, it is allowed.

As per the W3C specification, both the <section> and the <main> elements allow as content elements classified as flow content , which include the <header> and <footer> elements.

For example, a blog post:

<main>
    <header>
        <h1>Minha espetacular publicação<h1>
    </header>
    <section>
        <p>Ok, não é tão espetacular assim</p>
    </section>
    <footer>
        <time datetime="2018-08-28 20:00">Publicado em 2018-08-28 20:00</time>
    </footer>
</main>
Scroll to Top