简体   繁体   中英

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

I have the element: <div id="container-div" role="region"></div>

When the user will click the key 'R' I want the screen reader reads the words

"this is XXX area region"

without adding new label or element in the DOM.

(It's really important to keep the DOM clean without an extra hidden labels)

Just add an aria-label attribute, like this:

<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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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