"id" 和 "headers" 或 "scope" 数据 table 可访问性?

"id" and "headers" or "scope" for data table accessibility?

屏幕阅读器最支持哪种方法 - idheadersscope 属性?

我发现有关这些方法中的任何一种在将 HTML table headers 关联到 table 单元格时如何支持的相互矛盾的信息。

这取决于您的数据的复杂程度table。使用 scope 通常是最佳选择。

如果您使用 colspanrowspan,例如,使用 idheaders 将是更好的选择。

H43: Using id and headers attributes to associate data cells with header cells in data tables:

This technique is used when data cells are associated with more than one row and/or one column header. This allows screen readers to speak the headers associated with each data cell when the relationships are too complex to be identified using the th element alone or the th element with the scope attribute.

也就是说,当数据 table 需要此类补充属性时,其他人(不使用屏幕阅读器)可能很难将单元格与其 headers 相关联,并且可能是为 headers 提供补充视觉提示(如交替颜色或鼠标悬停效果等)的必要条件。