validator icon indicating copy to clipboard operation
validator copied to clipboard

No errors or warnings found for heading descendants of ARIA buttons

Open HadleyLuker opened this issue 7 months ago • 1 comments

Spec URL

https://w3c.github.io/html-aria/#index-aria-button

Test case

<div role="button">
  <h1>Lorem ipsum</h1>
</div>

<div role="button">
  <h2>Dolor sit</h2>
</div>

<div role="button">
  <h3>Amet consectetur</h3>
</div>

<div role="button">
  <h4>Adipiscing elit</h4>
</div>

<div role="button">
  <h5>Sed do</h5>
</div>

<div role="button">
  <h6>Eiusmod tempor</h6>
</div>

<div role="button">
  <div role="heading" aria-level="1">Incididunt ut</div>
</div>

HadleyLuker avatar Apr 22 '26 15:04 HadleyLuker

All of the examples are valid markup. As the linked html-aria spec states, a div with a button role may contain flow content such as headings.
I could see an argument for a warning for roles with "children presentational" but it's complicated - see for example https://github.com/w3c/aria/issues/2509.

Oh! I confused the two columns in the spec - sorry for the confusion.

pkra avatar Apr 23 '26 07:04 pkra