最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - aria-hidden property not working on descendants - Stack Overflow

programmeradmin3浏览0评论

Chrome Accessibility Tools plains that certain children of an overlay box do not have the right contrast ratio. It seems like the tool considers the children to be "visible" when the overlay is hidden.

I can see the aria-hidden property of the overlay being correctly set in the inspector as I open/close it, though (using attr("aria-hidden","false");).

Setting aria-hidden="true"; through the inspector on the children individually fixes this problem.

I am confused as aria-hidden is supposed to hide the element and its children. Does anyone know what I am doing wrong?

Chrome Accessibility Tools plains that certain children of an overlay box do not have the right contrast ratio. It seems like the tool considers the children to be "visible" when the overlay is hidden.

I can see the aria-hidden property of the overlay being correctly set in the inspector as I open/close it, though (using attr("aria-hidden","false");).

Setting aria-hidden="true"; through the inspector on the children individually fixes this problem.

I am confused as aria-hidden is supposed to hide the element and its children. Does anyone know what I am doing wrong?

Share Improve this question asked Jul 3, 2017 at 15:10 Vaida PlankyteVaida Plankyte 1131 gold badge1 silver badge6 bronze badges 2
  • Possible duplicate of What's the difference between HTML 'hidden' and 'aria-hidden' attributes? – GrumpyCrouton Commented Jul 3, 2017 at 15:21
  • hidden means hidden to everyone. aria-hidden means hidden to screen readers and similar tools – Hassan Imam Commented Jul 3, 2017 at 18:02
Add a ment  | 

1 Answer 1

Reset to default 6

Thank you for your ments, it made me realise I was indeed confused by what the audit tool was checking.

I used the advice given on the w3 website regarding putting [aria-hidden="true"] { visibility: hidden; } in my code, which properly hides the overlay when its aria-hidden property is set to true, and results in the audit tool being happy. :)

发布评论

评论列表(0)

  1. 暂无评论