简体   繁体   English

非标准表格数据的可访问性方法

[英]Accessibility Methodology for non-standard Table data

Issue Description:问题描述:

I am developing the UI for a list of advisor meetings.我正在为顾问会议列表开发 UI。 The list is formatted like a table, with a row of column headers and corresponding data.该列表的格式类似于表格,带有一行列标题和相应的数据。 Each meeting contains a row of data as well as a description section below that row.每个会议都包含一行数据以及该行下方的描述部分。 Each meeting card is also expandable to show additional data.每张会议卡也可展开以显示附加数据。 I am unsure of the best aria method to make this markup more accessible.我不确定使此标记更易于访问的最佳 aria 方法。

Screenshot of the UI I'm developing (actually a gif that shows the expand functionality)我正在开发的 UI 的屏幕截图(实际上是一个显示展开功能的 gif)

Goal:目标:

To make it easier for screen readers to easily navigate the list of meetings让屏幕阅读器更轻松地浏览会议列表

Potential Solutions:潜在的解决方案:

  1. Use aria attributes to construct a table for the elements that are in a table format ( https://www.w3.org/TR/wai-aria-practices-1.1/examples/table/table.html ) I'm not sure how navigable this would be, especially when it comes to navigating to the description section or the collapsible details section...使用 aria 属性为表格格式的元素构建表格 ( https://www.w3.org/TR/wai-aria-practices-1.1/examples/table/table.html ) 我不确定这将是多么可导航,尤其是在导航到描述部分或可折叠详细信息部分时......
  2. Hide the table header from screen readers and make the meeting wrappers li elements so that it forms a list.对屏幕阅读器隐藏表格标题并使会议包装器成为 li 元素,以便形成一个列表。 I would add hidden screen reader labels to each of the unlabeled values.我会为每个未标记的值添加隐藏的屏幕阅读器标签。 My concern is that the entire meeting is too much content for a li element and I'm not sure what the navigability for screen readers would be like.我担心的是,对于 li 元素,整个会议的内容太多,我不确定屏幕阅读器的可导航性会是什么样子。

I am certainly not an accessibility expert so I'm hoping that someone with more experience than me can point me towards the best practice / best implementation for a case like this.我当然不是可访问性专家,所以我希望比我更有经验的人可以为我指出此类案例的最佳实践/最佳实现。 Any suggestions would be much appreciated.任何建议将不胜感激。

From my own research for work, I have come up with the following pointers:从我自己的工作研究中,我提出了以下建议:

  • use the most specific and accurate html tag, and use css to style it the way you want (no need to make a button out of a span, a button's default styles can be overwritten)使用最具体和准确的 html 标签,并使用 css 按照您想要的方式对其进行样式设置(无需从 span 中制作按钮,按钮的默认样式可以被覆盖)
  • use case as much as possible to reduce unnecessarily nested html用例尽可能减少不必要的嵌套html
  • aria attributes are great, but should be a last resort. aria 属性很棒,但应该是最后的手段。

In the case of your table, I would say use the standard html table elements, just make sure to use the correct tags, like th , and make sure to include a description or label at the top of the table.对于您的表格,我会说使用标准的 html 表格元素,只需确保使用正确的标签,例如th ,并确保在表格顶部包含说明或标签。 Screen readers should know what to do with a table.屏幕阅读器应该知道如何处理表格。 If a table is the most accurate description of what you're building, use that :) Just be sure to use it in a standard and predictable way, and (see how often I say this) use only css for your styling.如果表格是您正在构建的内容的最准确描述,请使用它:) 请务必以标准和可预测的方式使用它,并且(请参阅我这么说的频率)仅使用 css 进行样式设置。

For the meetings there is an element for that: https://www.google.com/amp/s/www.geeksforgeeks.org/html5-details-tag/amp/ you can style it any way you want, but I think the arrow is chosen by the browser.对于会议,有一个元素: https : //www.google.com/amp/s/www.geeksforgeeks.org/html5-details-tag/amp/您可以随意设置样式,但我认为箭头由浏览器选择。 But a screen readers will read the summary and give the user the option to open it.但是屏幕阅读器会阅读摘要并为用户提供打开它的选项。 I think yours is a great use case for this element.我认为你是这个元素的一个很好的用例。

I wouldn't hide content like headers from screen readers.我不会对屏幕阅读器隐藏标题等内容。 People who use assistive technologies are used to navigating with them and headers are informative content.使用辅助技术的人习惯于使用它们进行导航,标题是信息性内容。

Kudos for considering accessibility in your code :)感谢您在代码中考虑可访问性 :)

Tables for Structure结构表

I would recommend staying away from tables, but that's my personal preference.我建议远离桌子,但这是我个人的喜好。 You could make this accessible using tables, but it would end up being more complicated than it needs to be.可以使用表格来访问它,但它最终会比它需要的更复杂。

List Structure列表结构

The list structure that you described would be fine, but ultimately you could convey the hierarchical structure of what you're doing here by using only headings and paragraphs.您描述的列表结构很好,但最终您可以通过仅使用标题和段落传达您在此处所做工作的层次结构。

Off-the-Shelf Solutions现成的解决方案

Many of the popular frontend frameworks (like Bootstrap, Material, etc.) have already solved the problem of accessible accordions , collapse elements , expansion panels , or whatever else you want to call it.许多流行的前端框架(如 Bootstrap、Material 等)已经解决了可访问的手风琴折叠元素扩展面板或其他任何你想称之为的问题。 Unless you're a strong JS developer, I would recommend starting with a pre-made solution from a well known framework and then testing using a decent screen reader .除非你是一个强大的 JS 开发人员,否则我建议从一个众所周知的框架的预制解决方案开始,然后使用一个像样的屏幕阅读器进行测试。

Custom Solutions定制解决方案

There's nothing wrong with implementing your own solution, assuming you have the skillset and time available to do so.假设您有足够的技能和时间来实施自己的解决方案,那么实施自己的解决方案并没有错。

W3C has some great guidance on the desired behavior of accessible accordion elements , and the A11Y project has a nice design pattern library with usable code samples. W3C 对可访问的手风琴元素的所需行为有一些很好的指导,A11Y 项目有一个很好的设计模式库,其中包含可用的代码示例。

For the ARIA markup, you'll need to make use of aria-expanded , aria-controls and aria-labelledby respectively.对于 ARIA 标记,您需要分别使用aria-expandedaria-controlsaria-labelledby Depending on how your screen reader tests go, you may also wish to set focus when the expandable element opens.根据您的屏幕阅读器测试进行的方式,您可能还希望在可扩展元素打开时设置焦点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM