How does CSS opacity affect accessibility?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 05:50:20

While this is an older question, it was one of the first that surfaced in a Google search, so I wanted to chime in.

As of April 2017, the ChromeVox screen reader does not read content that is set to opacity 0.

Specifically, ChromeVox won't read text that has been visually hidden with opacity set to zero, unless the element is labeled by visually available text.

For example:

<!-- will not be read -->
<a href="#!" style="opacity: 0;">not read</a>

<!-- WILL be read -->
<a href="#!" style="opacity: 0.001;">is read</a>

<!-- span text will not be read -->
<a href="#!">
  Read More
  <span style="opacity: 0;">
    this will not be read
  </span>
</a>

<!-- 
  button text will not be read, 
  but aria-labelledby text will be read on button focus 
-->
<span id="test">button label</span>
<button type="button" aria-labelledby="test" style="opacity: 0;">
  This text will not be read
</button>

opacity: 0; won't hide content from screen readers, though it'll hide content from sighted users and partially sighted users.
It's like displaying a white text on a white background (or transparent, you get the idea).
It'll be mapped to the accessibility API, you should still see the pointer changing above links, edit: you can still select text /edit, and somebody should test to see if, when tabulating links and form elements, the default dotted outline will display as usual or will be transparent. Edit: the latter, just tested with Firebug on this page.

Opacity is a transparency factor so opacity:0 means not visible. If you say about display:none and visibility:hidden remeber the difference is that display disappears completely some object, container and it doesn't have any size whilst visibility makes non-visibility but it still has some size on page.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!