DEV Community

Calin Baenen
Calin Baenen

Posted on

Which is better orwith more standard, ID on the header or ID on the `<section>`?

Say I had a situation like this:

<section>
  <h2>Section Name</h2>

  <!-- ... -->
</section>
Enter fullscreen mode Exit fullscreen mode

What would better/more standard, putting the ID on the <section> element, like so:

<section id="section-name">
  <!-- ... -->
</section>
Enter fullscreen mode Exit fullscreen mode

or on the header, like so:

<section>
  <h2 id="section-name">Section Name</h2>

  <!-- ... -->
</section>
Enter fullscreen mode Exit fullscreen mode
Thanks in advance!
Cheers!

Top comments (0)