何时对 HTML 元素使用 disabled 属性与 aria-disabled 属性? [英] When to use the disabled attribute vs the aria-disabled attribute for HTML elements?
问题描述
我正在尝试使表单易于访问.我应该让我的输入同时具有 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>
或者像这样?
<label for="textbox1">Input</label>
<input id="textbox1" type="text" name="Text Box" aria-disabled="true">
或者像这样?
<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 Faulkner(ARIA 规范的编辑之一)从 2015 年开始的这篇文章中阅读更多关于可以转储的 ARIA 属性(尽管 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/
如果我的回答类似于 您关于required
与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屋!