ARIA: Listitem role - Accessibility 编辑

The ARIA listitem role can be used to identify an item inside a list of items. It is normally used in conjunction with the list role, which is used to identify a list container.

<section role="list">
  <div role="listitem">List item 1</div>
  <div role="listitem">List item 2</div>
  <div role="listitem">List item 3</div>
</section>

Description

Any content that consists of an outer container with a list of elements inside it can be identified to assistive technologies using the list and listitem containers respectively.

There are no hard and fast rules about which elements you should use to markup the list and list items, but you should make sure that the list items make sense in the context of a list, e.g. a shopping list, recipe steps, driving directions.

Warning: If at all possible in your work, you should use the appropriate semantic HTML elements to mark up a list and its listitems — <ul>/<ol> and <li>. See Best practices for a full example.

Associated WAI-ARIA Roles, States, and Properties

list

A list of items. Elements with role list must have one or more elements with the role listitem as children, a one or more elements with the role of group that have one or more elements with the listitem role as children.

group

A collection of related objects, limited to list items when nested in a list, not important enough to have their own place in a pages table of contents.

Keyboard Interactions

None.

Required JavaScript features

None.

Examples

 ARIA Lists — some useful examples and thoughts by Scott O'Hara

Best practices

Only use role="list" and role="listitem" if you have to — for example if you don't have control over your HTML but are able to improve accessibility dynamically after the fact with JavaScript.

If at all possible, you should use the appropriate semantic HTML elements to mark up a list and listitems — <ol>/<ul> and <li>. For example, our above example should be rewritten as follows:

<ul>
  <li>List item 1</li>
  <li>List item 2</li>
  <li>List item 3</li>
</ul>

or use an ordered list if the order of the list items matters:

<ol>
  <li>List item 1</li>
  <li>List item 2</li>
  <li>List item 3</li>
</ol>

Note: The ARIA list/listitem roles don't distinguish between ordered and unordered lists.

Note: If you are marking up a list of items that will function as a tabbed interface, you should instead use the tab, tabpanel, and tablist roles.

Specifications

SpecificationStatus
Accessible Rich Internet Applications (WAI-ARIA) 1.1
The definition of 'listitem' in that specification.
Recommendation

Screen reader support

TBD

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:127 次

字数:6660

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文