简体   繁体   English

为属性添加描述(用于屏幕阅读器),而无需添加新标签/元素

[英]Add a Description to Attribute (for Screen Reader) Without Adding New Label / Element

I have the element: <div id="container-div" role="region"></div> 我有一个元素: <div id="container-div" role="region"></div>

When the user will click the key 'R' I want the screen reader reads the words 当用户单击键“ R”时,我希望屏幕阅读器读取以下单词:

"this is XXX area region" “这是XXX地区区域”

without adding new label or element in the DOM. 无需在DOM中添加新标签或元素。

(It's really important to keep the DOM clean without an extra hidden labels) (保持DOM干净而没有额外的隐藏标签非常重要)

Just add an aria-label attribute, like this: 只需添加一个aria-label属性,如下所示:

<div id="container-div" role="region" aria-label="This is an XXX">

Tip: don't use the word Region in your description since screen readers (at least JAWS) add it themselves. 提示:请勿在描述中使用“区域”一词,因为屏幕阅读器(至少是JAWS)会自行添加。 So, if you write "This is an XXX area region", a screen reader would say "This is an XXX area region region" because of the role. 因此,如果您写“这是XXX区域区域”,则屏幕阅读器会由于该角色而显示“这是XXX区域区域”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM