Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Must role="tab" be the direct child of a role="tablist"?

I have an accordion which is structured like:

<section... role="tablist">
  <div>
    <h3 role="tab">Title</h3>
    <div role="tabpanel">
    ...
    </div>
  </div>
</section>

Does tab have to be a direct child of the tablist to conform to wai aria best practices or is it okay to be wrapped in a div?

like image 577
RedHorse Avatar asked Dec 07 '25 04:12

RedHorse


1 Answers

Authors MUST ensure elements with role tab are contained in, or owned by, an element with the role tablist.

https://www.w3.org/TR/wai-aria-1.1/#tab

Your example is therefore correct.

I would suggest you read through the spec to ensure you are following best ARIA practice.

For example adding the role on a div as opposed to a section element, as per the best practice example.

like image 65
Shannon Young Avatar answered Dec 09 '25 19:12

Shannon Young



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!