What is sr-only in Bootstrap 3?

后端 未结 6 861
猫巷女王i
猫巷女王i 2020-11-22 09:23

What is the class sr-only used for? Is it important or can I remove it? Works fine without.

Here\'s my example:

6条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 10:15

    As JoshC said, the class .sr-only is used to visually hide the information used for screen readers only. But not only to hide labels. You might consider hiding various other elements such as "skip to main content" link, icons which have an alternative texts etc.

    BTW. you can also use .sr-only sr-only-focusable if you need the element to become visible when focused e.g. "skip to main content"

    If you want make your website even more accessible I recommend to start here:

    • Accessibility @Google - Web Fundamentals
    • Accessibility Developer Guide (my personal favorite)
    • WebAIM Principles + WebAIM WCAG Checklist
    • Accessibility @ReactJS (lots of good resources and general stuff)

    Why?

    According to the World Health Organization, 285 million people have vision impairments. So making a website accessible is important.

    IMPORTANT: Avoid treating disabled users differently. Generally speaking try to avoid developing a different content for different groups of users. Instead try to make accessible the existing content so that it simply works out-of-the-box and for all not specifically targeting e.g. screen readers. In other words don't try to reinvent the wheel. Otherwise the resulting accessibility will often be worse than if there was nothing developed at all. We developers should not assume how those users will use our website. So be very careful when you need to develop such solutions. Obviously a "skip link" is a good example of such content if it's made visible when focused. But there many bad examples too. Such would be hiding from a screen reader a "zoom" button on the map assuming that it has no relevance to blind users. But surprisingly, a zoom function indeed is used among blind users! They like to download images like many other users do (even in high resolution), for sending them to somebody else or for using them in some other context. Source - Read more @ADG: Bad ARIA practices

提交回复
热议问题