Skip to content

aria-sort forces role="columnheader" or rowheader Validation throws error on <th>  #592

Closed

Description

@DavidMacDonald

The wayaria-sort it is written, it is invalid HTML to rely on the <th> like this:

<th aria-sort="acsending">

There is a thread here:

w3c/html#909

@stevefaulkner
@sideshowbarker

Said the issue is with wai-aria. Here's the issue:

  • using aria-sort requires role="columnheader" or rowheader
  • ARIA currently maps <th> to role="cell" which provides no appreciable semantics to distinguish a header from a data cell, forcing the author to use role="columnheader" or rowheader this is an extra step for authors.
  • This could be made simpler by introducing an new generic role="tableheader". This would be an optional role to the more specific rowheader and columnheader.
  • The A11Y API could then map the <th> to role="tableheader".
  • We could then allow authors to use <th aria-sort="ascending"> without burdening them with a role, because the <th> semantics would be sufficient.

The first rule of ARIA is to use generic HTML when possible. It seems with this minor tweak, we could make it easier for authors to use aria-sort. There are no implications on screen readers which already understand what the th does. They ignore the unhelpful role="cell" mapping in the API.

Activity

  1. hartman commented on Jun 29, 2017

    @hartman

    Just wondering, but i'm guessing that scope is not really affecting this either is it ? Should it ?

    https://www.w3.org/TR/wai-aria-1.1/#columnheader
    base concept: th[scope="col"]

    I guess it should.. It's not super explicit. Wonder what most the software does on this front.

    I tested:

    • Safari: default of <th> is cell indeed, when using scope=col or <thead>, the default role becomes columnheader
    • Chrome: Does not change the <th> role when using scope=col or <thead>
  2. hartman commented on Jun 29, 2017

    @hartman

    And on that note. What about thead ? <th> cells inside a <thead> should be reasonably safe to assume to be column headers right ?

  3. DavidMacDonald commented on Jul 3, 2017

    @DavidMacDonald
    Author

    I think scope doesn't do that much these days, but its good to know that Safari changes the role to column header instead of the unhelpful role="cell"

    We "could" say:

    • th with scope="col" map to role="columnheader"
    • th with scope="row" map to role="rowheader"
    • th inside thead map to role="columnheader"

    I think we should do that, but that still requires the author to add the scope or thead.

    I think the addition a new role="tableheader" will be the most elegant because it would allow the implicit mapping of th to that role, and then the author could simply do <th aria-sort="ascending">

  4. hartman commented on Jul 4, 2017

    @hartman
  5. DavidMacDonald commented on Jul 14, 2017

    @DavidMacDonald
    Author

    @hartman We wrote that technique about 15 years ago, in the early days of WCAG. Screen readers have largely overcome the need for scope except in limited situations.

  6. jnurthen commented on Sep 30, 2019

    @jnurthen
    Member

    Looks like HTML-AAM was updated to map th to columnheader or rowheader - closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions