Html辅助功能-读取另一个元素的说明

vybvopom  于 2022-12-09  发布在  其他
关注(0)|答案(1)|浏览(119)

您好,所有的无障碍Maven,
我想让这个button元素,当标签打开时,会触发input元素的屏幕读取。
我试着将aria-labelledbybutton指向input,以便读出inputaria-label。但是当标签打开时,button仍然读出它自己的描述。

<fieldset>
    <input type="radio" id="inputid" aria-label="read me">
    <button aria-labelledby="inputid">don't read me</button>
</fieldset>

是否有办法读取另一个元素的内容?
谢谢你的好意,
2022年12月6日编辑:根据Andy的评论,input元素只是在视觉上隐藏了,所以它被css left: -10000px移到了屏幕外。

dzjeubhm

dzjeubhm1#

I believe aria-labelledby is not used according to the standards, which might explain undefined behaviour.
The Accessible Name and Description, step C mentions the following:
If the embedded control has role textbox, return its value.
That means that if an <input> , which has implicit role textbox , is used as part of an accessible name, not its label, but its value is used as the name.
Further, the ARIA standard on aria-labelledby reads:
If the interface is such that it is not possible to have a visible label on the screen, authors SHOULD use aria-label […]
The main purpose of aria-labelleby is to refer to part of the visible contents of an element like a <form> to label it. Most commonly, this would be a heading like <h2> .
The use case of this question is currently unclear to me. The example provided does not make sense with a single radio input.

  • If the <input> is completely hidden, visually and from assistive technology, why is it there in the first place? <input type="hidden"> would be the more correct input to use if the form data is needed
  • If it’s only hidden visually, both the button and the input can be focussed, which is terribly confusing. Does the input appear on screen once it receives focus?

相关问题