何时对HTML元素使用disabled属性和aria-disabled属性? [英] When to use the disabled attribute vs the aria-disabled attribute for HTML elements?

查看:7399
本文介绍了何时对HTML元素使用disabled属性和aria-disabled属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使表单可以访问。我应该让我的输入既有禁用 aria-disabled 属性,或者只有一个属性?

I'm trying to make a form accessible. Should I make my inputs have both disabled and aria-disabled attributes, or just one?

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" disabled>

或者像这样?

Or like this?

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" aria-disabled="true">

或者像这样?

Or like this?

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" aria-disabled="true" disabled>


推荐答案

我可以拿你的例子,把它放在在CodePen中,并在JAWS和NVDA中检查(对不起,今天没有VoiceOver):

I can take your example, put it in a CodePen, and check it in JAWS and NVDA (sorry, no VoiceOver today):

<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" disabled>

您将很高兴知道NVDA和JAWS都会跳过该字段(或者如果明确关注,这是禁用的)。

You will be happy to know that both NVDA and JAWS skip the field (or if explicitly focused, announce that is disabled).

总之,您不需需要 aria-disabled 不再。只需使用 disabled

In short, you do not need aria-disabled any longer. Just use disabled.

您可以阅读更多关于您可以通过Steve在本文中转储的ARIA属性Faulkner(ARIA规范的编辑之一)从2015年开始(尽管 aria-disabled 未明确列出,但概念相同): http://html5doctor.com/on-html-belts-and-aria-braces/

You can read a bit more about the ARIA attributes you can dump in this article by Steve Faulkner (one of the editors of the ARIA spec) from 2015 (though aria-disabled is not explicitly listed, the concept is the same): http://html5doctor.com/on-html-belts-and-aria-braces/

如果我的回答看起来类似于你的另一个问题关于要求 aria-required ,这是因为它本质上是相同的答案。

If my answer looks similar to your other question about required versus aria-required, that is because it is essentially the same answer.

这篇关于何时对HTML元素使用disabled属性和aria-disabled属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆