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)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay