w3c / html-aria

ARIA in HTML
https://w3c.github.io/html-aria/
Other
181 stars 48 forks source link

Clarify implicit roles for <th> #244

Closed AlexLloyd0 closed 3 years ago

AlexLloyd0 commented 3 years ago

The implicit semantics for th are described as

If a descendant of a table element, role=columnheader or rowheader or cell (if not a header).

If a descendant of a table element with role=grid or treegrid, role=columnheader or rowheader or gridcell (if not a header).

But it's not clear under which conditions a <th> should take each role.

https://github.com/w3c/html-aria/issues/61#issuecomment-294574702 suggests an algorithm. Chrome behaves differently to this though, something like:

scottaohara commented 3 years ago

HTML AAM / the HTML spec would be the places to call this out. We can point to the HTML spec / HTML AAM for more info, though. But I do think it's worth re-investigating if th is exposed as a cell in any modern browsers.

AlexLloyd0 commented 3 years ago

Ah yes, it is already in the HTML AAM spec, in the th entries at https://www.w3.org/TR/html-aam-1.0/#html-element-role-mappings. I'll create a PR adding a link to that spec.

As for whether browsers ever expose th as a cell, I've found one case in which Chrome (incorrectly) calls a <th> a gridcell (below) but haven't found a cell.

<table>
  <tr>
    <td>d</td>
    <th>h</th>
  </tr>
  <tr>
    <td>d</td>
    <td>d</td>
  </tr>
</table>
scottaohara commented 3 years ago

yes, i've noticed chrome having some odd roles exposed in the browser panel lately. haven't gotten around to seeing if they're incorrectly exposed at the platform level or if it's just the a11y panel in the browser that's quirky here. will investigate that later...

anyway, thank you logging this / making the pr.

scottaohara commented 3 years ago

closed via #246