-
Notifications
You must be signed in to change notification settings - Fork 75
Table headers - No ARIA tables and TF feedback #1971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Why the rule focuses on HTML tables only and explaining how browsers treat columns and rows with one td
- **visible** the `table` element is [visible][]; and | ||
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and | ||
- **non-empty data cell** the `table` element has at least one non-empty `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child]. | ||
- **no explicit role** none of the elements that make up the [table model][] have an [explicit semantic role][]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the explicit role is the same as the implicit one? (<th role="rowheader">
)
Plus, this seems to be a bullet in the outer list (used by the th
) but rather refers to the table
(i.e. the inner list).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've chosen the safer version as we don't know for sure what browsers do when aria roles are added as it's not in the spec. UA have their own way of assigning headers when aria is used and at the moment we can only guess. I understand that the same implicit role would work fine in practice but I'm slightly concerned we may expose the rule to some weird, uncommon example that will be a false positive.
Do you think the rule will benefit from adding an exception for the same explicit role?
Hmm... this role applies to all the elements that make up the test target's table element, so table
,thead
, tbody
,tr
, etc. I thought that the table model definition was explicit enough. Open to suggestions on this.
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true: | ||
- **visible** the `table` element is [visible][]; and | ||
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and | ||
- **non-empty data cell** the `table` element has at least one non-empty `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child]. | ||
- **no explicit role** none of the elements that make up the [table model][] have an [explicit semantic role][]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the th
element is no more required to be visible or included in the accessibility tree 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, not sure what you mean by this. Are you suggesting that the "included in the accessibility tree" part in the first paragraph of the applicability section is not necessary?
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true: | ||
- **visible** the `table` element is [visible][]; and | ||
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and | ||
- **non-empty data cell** the `table` element has at least one non-empty `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child]. | ||
- **no explicit role** none of the elements that make up the [table model][] have an [explicit semantic role][]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid the nested lists will prove difficult to read.
What about defining a "proper table" or something as a table
element matching all the conditions here, and just require the th
to be "part of a proper table"? The def might be re-usable by other rules about HTML tables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, sounds good to me!
- the element's closest ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][] is [included in the accessibility tree][]. | ||
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true: | ||
- **visible** the `table` element is [visible][]; and | ||
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Not fully sure about that one.
<table>
<tr>
<th>Opening hours</th> <td>8-17</td>
</tr>
</table>
sounds like a reasonable case.
And
<table>
<tr>
<th>Opening hours</th> <th>Mon-Fri</th> <td>8-17</td>
</tr>
</table>
sounds like a bad one (where the first th
is not assigned to anything due to the second one (or maybe it is still assigned to the second th
, can't remember…))
(OTOH, restricting Applicability won't create false positives, so it won't really hurt…)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with Jean-Yves. The first case is reasonable, and I can't come up with a good reason for us to ignore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is how much value we get out of that example? Not too much if you think that there is only one row and row headers are useful when you navigate between the rows. This change corresponds to Wilco's survey comments. I'm trying to avoid the below scenario:
<table>
<thead>
<tr>
<td>N/a
<th>2008
<th>2007
<th>2006
<tbody>
<tr>
<td>
<td>
<td>
<td>
</table>
Because tables are two dimensional the most we will get out of this rule if there will be at least two rows and there will be a non-empty data cell in a row that follows a column header row or in any of the rows providing that there are row headers in them.
Would you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how your example applies to this condition (your example has 2 rows, therefore this conditions applies) :-)
But I can live with this condition. As Jean-Yves mentioned, it will only limit what is applicable, not create false positives. Although I still can't see why we should not consider the one row example Jean-Yves described.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem that the above example introduces is that there is no use of the <th>
elements, technically they do not have an assigned <td>
element and they should not be column headers but the implementation varies. My condition requires at least one non-empty <td>
element in the second row, meaning that it is clear visually that there is a relationship between a data cell and a column header cell.
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true: | ||
- **visible** the `table` element is [visible][]; and | ||
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and | ||
- **non-empty data cell** the `table` element has at least one non-empty `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not sure about that due to multi-headers.
Opening hours:
<table>
<tr>
<th rowspan="2">Morning</th> <th>Mon-Fri</th> <td>8-12</td>
</tr>
<tr>
<!-- no first column --> <th>Sat-Sun</th> <td>10-12</td>
</tr>
<table>
would have at least 2 th
children in the first row without it being a "headers row".
(here also, no real harm in restricting the Applicability)
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Failed Example 1</title> | ||
<style> | ||
table { | ||
border-collapse: collapse; | ||
border: hidden; | ||
} | ||
tr td, | ||
tr th { | ||
border: 1px solid grey; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Rate</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>15%</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Failed Example 1</title> | |
<style> | |
table { | |
border-collapse: collapse; | |
border: hidden; | |
} | |
tr td, | |
tr th { | |
border: 1px solid grey; | |
} | |
</style> | |
</head> | |
<body> | |
<table> | |
<thead> | |
<tr> | |
<th>Rate</th> | |
<th>Value</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>15%</td> | |
</tr> | |
</tbody> | |
</table> | |
</body> | |
</html> | |
<style> | |
table { | |
border-collapse: collapse; | |
border: hidden; | |
} | |
tr td, | |
tr th { | |
border: 1px solid grey; | |
} | |
</style> | |
<table> | |
<thead> | |
<tr> | |
<th>Rate</th> | |
<th>Value</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>15%</td> | |
</tr> | |
</tbody> | |
</table> |
(not sure how much the style is needed, though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it should be added in response to @kengdoj comment
From https://www.w3.org/TR/wai-aria-1.1/#columnheader: The columnheader establishes a relationship between it and all cells in the corresponding column. When there are no cells under a column header (as in Fail Ex 1), I don't think 1.3.1 requires that it can't be a column header without a data cell.
My point here is, visually looks like there is a cell for the second column header but programmatically there isn't one so it is a failure. Would you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That pasted comment is from Q5 in the survey so I was a bit confused.
My survey comment for this example was in Q4 and is below. It didn't look like there's a cell to me, though I can understand that someone may assume one:
Fail Ex 1's table has no data cell under the second column and programmatically matches the presentation. Not sure this is a failure of 1.3.1.
- the element's closest ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][] is [included in the accessibility tree][]. | ||
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true: | ||
- **visible** the `table` element is [visible][]; and | ||
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with Jean-Yves. The first case is reasonable, and I can't come up with a good reason for us to ignore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some issues to keep working on
- the element is [included in the accessibility tree][]; and | ||
- the element has at least one ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][]; and | ||
- the element's closest ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][] is [included in the accessibility tree][]. | ||
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true: | |
- **in a table**: the `th` element is a [descendant][] of a `table` element for which all of the following are true: |
Need to add the colon after the name of all conditions
- the element's closest ancestor in the [flat tree][] that is a [semantic][semantic role] [table][] or [grid][] is [included in the accessibility tree][]. | ||
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true: | ||
- **visible** the `table` element is [visible][]; and | ||
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how your example applies to this condition (your example has 2 rows, therefore this conditions applies) :-)
But I can live with this condition. As Jean-Yves mentioned, it will only limit what is applicable, not create false positives. Although I still can't see why we should not consider the one row example Jean-Yves described.
- **in a table** the `th` element is a [descendant][] of a `table` element for which all of the following are true: | ||
- **visible** the `table` element is [visible][]; and | ||
- **minimum rows** the `table` element's [`rows` collection](https://html.spec.whatwg.org/multipage/tables.html#dom-table-rows) has 2 or more `tr` elements; and | ||
- **non-empty data cell** the `table` element has at least one [non-empty][] `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- **non-empty data cell** the `table` element has at least one [non-empty][] `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child] or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child]. | |
- **non-empty data cell** the `table` element has at least one [non-empty][] `td` element that is a [child][] of a `tr` element with the [`rowIndex`][rowindex] value of 1 or more if the `tr` element with the value of 0 has at least two `th` [children][child]; or the value of 0 or more if the `tr` element with the value of 0 has one or less `th` [children][child]. |
Interestingly, this condition would make Jean-Yves' one row example, applicable.
Hi @HelenBurge |
A few of changes to Table header cell has assigned cells.
The only reliably way of determining how table headers are assigned is in the HTML specification. It is unclear how ARIA table headers are assigned to cells so they are now omitted from the rule.
The update includes changes made in response to the 1st Task Force feedback and the 2nd Task Force feedback.
Closes #1545 and closes #1517
Call for review- 2 weeks
How to Review And Approve