没有 ARIA 胜过糟糕的 ARIA。
No ARIA is better than bad ARIA

原始链接: https://www.w3.org/WAI/ARIA/apg/practices/read-me-first/

## ARIA:谨慎使用 ARIA(可访问的富互联网应用)增强了辅助技术(如屏幕阅读器)的可访问性,就像CSS之于视觉体验。但是,**不正确的ARIA实现可能比根本不使用它更糟糕。** 两个核心原则至关重要:**ARIA角色是一种承诺。** 将元素声明为“按钮”并使用`role="button"` *需要* 伴随的JavaScript来提供预期的按钮功能(如键盘交互)。仅角色本身并不会添加此行为。 其次,**ARIA既可以增强*又*可以覆盖现有的可访问性信息。** 它可以添加缺失的语义,但也可以*掩盖*元素的原始含义,从而可能误导用户。 因此,使用各种浏览器和辅助技术进行彻底测试至关重要。本指南重点介绍根据规范定义的*正确* ARIA用法,而不是浏览器/辅助技术不一致的解决方法。 滥用ARIA可能会造成可访问性障碍,因此请在实施之前优先了解其含义。

## 黑客新闻讨论:ARIA 与 Web 可访问性 最近一篇黑客新闻帖子引发了关于实施可访问的富互联网应用 (ARIA) 以实现 Web 可访问性的复杂性的争论。核心信息,呼应了 W3.org 的声明,是 **“没有 ARIA 胜过糟糕的 ARIA。”** 许多开发者觉得 ARIA 令人困惑,官方指南通常建议除非绝对必要,否则不要使用它。 讨论强调了对 ARIA 复杂性的沮丧,以及缺乏现成的、可用于生产环境的示例。用户强调了 **语义化 HTML** 作为基础的重要性,并警告不要将 ARIA 作为对结构糟糕的代码的“拐杖”。 一个关键主题是 **直接用户测试** 的必要性——理想情况下是与屏幕阅读器用户一起进行——以真正理解可访问性问题。 许多评论者提倡开发者*亲自*使用屏幕阅读器体验网站,并建议使用 Guidepup 等工具进行自动化测试。 人们越来越有兴趣利用 **人工智能代理** 来自动化可访问性测试,通过模拟屏幕阅读器交互来实现。 最终,这次对话强调了实现真正可访问性的挑战,以及超越简单地检查清单,创造真正包容的 Web 体验的必要性。
相关文章

原文

No ARIA is better than Bad ARIA

Functionally, ARIA roles, states, and properties are analogous to a CSS for assistive technologies. For screen reader users, ARIA controls the rendering of their non-visual experience. Incorrect ARIA misrepresents visual experiences, with potentially devastating effects on their corresponding non-visual experiences.

Before using ARIA or any of the guidance in this document, please take time to understand the following two essential principles.

Principle 1: A role is a promise

This code:

<div role="button">Place Order</div>

Is a promise that the author of that <div> has also incorporated JavaScript that provides the keyboard interactions expected for a button. Unlike HTML input elements, ARIA roles do not cause browsers to provide keyboard behaviors or styling.

Using a role without fulfilling the promise of that role is similar to making a "Place Order" button that abandons an order and empties the shopping cart.

One of the objectives of this guide is to define expected behaviors for each ARIA role.

Principle 2: ARIA Can Both Cloak and Enhance, Creating Both Power and Danger

The information assistive technologies need about the meaning and purpose of user interface elements is called accessibility semantics. From the perspective of assistive technologies, ARIA gives authors the ability to dress up HTML and SVG elements with critical accessibility semantics that the assistive technologies would not otherwise be able to reliably derive.

Some of ARIA is like a cloak; it covers up, or overrides, the original semantics or content.

<a role="menuitem">Assistive tech users perceive this element as an item in a menu, not a link.</a>
  <a aria-label="Assistive tech users can only perceive the contents of this aria-label, not the link text">Link Text</a>

On the other hand, some uses of ARIA are more like suspenders or belts; they add meaning that provides essential support to the original content.

<button aria-pressed="false">Mute</button>

This is the power of ARIA. It enables authors to describe nearly any user interface component in ways that assistive technologies can reliably interpret, thus making components accessible to assistive technology users.

This is also the danger of ARIA. Authors can inadvertently override accessibility semantics.

<table role="log">
  <!--
    Table that assistive technology users will not perceive as a table.
    The log role tells browser this is a log, not a table.
  -->
</table>
<ul role="navigation">
  <!-- This is a navigation region, not a list. -->
  <li><a href="uri1">nav link 1</a></li>
  <li><a href="uri2">nav link 2</a></li>
  <!-- ERROR! Previous list items are not in a list! -->
</ul>

Browser and Assistive Technology Support

Testing assistive technology interoperability is essential before using code from this guide in production. Because the purpose of this guide is to illustrate appropriate use of ARIA 1.2 as defined in the ARIA specification, the design patterns, reference examples, and sample code intentionally do not describe and implement coding techniques for working around problems caused by gaps in support for ARIA 1.2 in browsers and assistive technologies. It is thus advisable to test implementations thoroughly with each browser and assistive technology combination that is relevant within a target audience.

Similarly, JavaScript and CSS in this guide is written to be compatible with the most recent version of Chrome, Firefox, and Safari at the time of writing.

Except in cases where the ARIA Working Group and other contributors have overlooked an error, examples in this guide that do not function well in a particular browser or with a specific assistive technology are demonstrating browser or assistive technology bugs. Browser and assistive technology developers can thus utilize code in this guide to help assess the quality of their support for ARIA 1.2.

联系我们 contact @ memedata.com