What is sr-only in Bootstrap 3?

This article was translated from: What is sr-only in Bootstrap 3?

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

Here's my example: This is my example:

<div class="btn-group">
    <button type="button" class="btn btn-info btn-md">Departments</button>
    <button type="button" class="btn btn-info dropdown-toggle btn-md" data-toggle="dropdown">
    <span class="caret"></span>
    <span class="sr-only">Toggle Dropdown</span>
    </button>
    <ul class="dropdown-menu" role="menu">
        <li><a href="#">Sales</a></li>
        <li><a href="#">Technical</a></li>
        <li class="divider"></li>
        <li><a href="#">Show all</a></li>
    </ul>
</div>

#1st Floor

Reference: What is sr-only in https://stackoom.com/question/1Ku74/Bootstrap-


#2nd Floor

To ACCORDING bootstrap's Documentation , at The class IS Used to hide Information Intended only for Screen Readers from at The layout of at The Page rendered. According to bootstrap documentation , the class used to hide only from showing the layout of the pages in screen readers information .

Screen readers will have trouble with your forms if you don't include a label for every input. If you don't add labels for every input , then screen readers will cause trouble for your forms. For these inline forms, you can hide the labels using the .sr-only class. For these inline forms, you can use the .sr-only class to hide the labels.

IS AN here Wallpaper Example Styling Used: This is the style used examples :

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

Is it important or can I remove it? Is it important or can I remove it ? Works fine without. Works fine without .

It's important, don't remove it. Importantly, don't remove it .

You should always consider screen readers for accessibility purposes. You should always consider screen readers for accessibility features. Usage of the class will hide the element anyways, therefore you shouldn't see a visual difference. Using this class will hide the element anyway, so you should not see the visual difference.

If you're interested in reading about accessibility: If you are interested in reading about accessibility :


#3rd floor

As JoshC said, the class is used to hide information used for screen readers. As JoshC said, this class is used to hide information used for screen readers . But not only to hide labels, you might consider to hide from sighted user an internal link "skip to main content" which is desirable for blind users if you have a complex navigation or ads before the main content. However, not only to hide the label, You can also consider hiding internal links to "skip to main content" from users with poor eyesight. If you have complicated navigation or advertising before the main content, this is ideal for blind people.

If you want your site to interact even more with screen readers, use W3C standardized ARIA attributes and I definitely recommend to visit the Google online course , which will take only up to 1-2h or at least watch a Google's 40min video . If you want your website more interactive screen reader, please use the standardized W3C ARIA attributes, I definitely recommend that you visit the Google online courses , the course requires a maximum of 1-2 hours, or at least watch Google 40 minutes of video .

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

UPDATE 2019: Update 2019:

As developers we should make accessible content that simply works for all out-of-the-box and not specifically target screen readers. As developers, we should provide accessible content that applies only to all ready-to-use content, not specifically The content of the screen reader. That's not always possible but be careful using ARIA and "screen reader only" adjustments . This is not always possible, but please use ARIA and "screen reader only" adjustments with caution . Don't do it if you don't fully understand it. If you don't fully understand it , please don't do it. Incorrect implementation might be much worse than not using it whatsoever. Incorrect implementation might be much worse than not using it whatsoever . Please read accessibility-developer-guide on ARIA bad examples . Please read accessibility-developer-develop about ARIA error examples . There you will find as well fully accessible components / widgets which does not require any "screen reader only" interventions. There you will find fully accessible components / widgets without any "screen reader only " intervention.


#4th floor

At The found the this in the I navbar Example , and Simplified IT. I navbar example, we found it, and its simplified.

<ul class="nav">
  <li><a>Default</a></li>
  <li><a>Static top</a></li>
  <li><b><a>Fixed top <span class="sr-only">(current)</span></a></b></li>
</ul>

You see which one is selected ( sr-onlypart is hidden): You will see which one is selected ( part is hidden ):sr-only

  • Default Default
  • Static top static headspace
  • Fixed top fixed roof

You hear which one is selected if you use screen reader: If you use a screen reader, you will hear which option is selected:

  • Default Default
  • Static top static headspace
  • Fixed top (current) Fixed top (current)

As a result of this technique blind people supposed to navigate easier on your website. Because of this technology, blind people should have navigated easier on your website .


#5th Floor

Ensures that the object is displayed (or should be) only to readers and similar devices. Ensure that the object is displayed (or should be) only to readers and similar devices . It give more sense in context with other element with attribute aria-hidden = "true" . Compared with other elements with aria-hidden = "true" attribute , it has more meaning in context.

<div class="alert alert-danger" role="alert">
  <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
  <span class="sr-only">Error:</span>
  Enter a valid email address
</div>

Glyphicon will be displayed on all other devices, word Error: on text readers. Glyphicon will be displayed on all other devices, and an error will appear on the text reader : words.


#6th floor

.sr-onlyis a class name specifically used for screen readers. .sr-onlyIs a class name specifically used for screen readers . You can use any class name, but .sr-onlyis pretty commonly used. You can use any class name, but it .sr-onlyis very common. If you don't care about developing with compliance in mind, then it can be removed. If you don't care about developing with compliance in mind , you can remove it. It will not affect UI in any way if removed because the CSS for this class is not visible to desktop and mobile device browsers. If it is removed, it will not affect the UI in any way , because this type of CSS has an effect on desktop and mobile The device browser is not visible.

Seems to some BE Information There Missing here Wallpaper at The use of the About .sr-onlyto EXPLAIN the ITS Purpose and being for Screen Readers. There seems to be lack of information on .sr-onlythe use .sr-onlyto interpret the information for the purpose and use of a screen reader. First and foremost, it is very important to always keep impaired users in mind. First, the most important thing is to always keep the impaired users in mind . Impairment is the purpose of 508 compliance: https://www.section508.gov/ , and it is great that bootstrap takes this into consideration. Impairment is the purpose of 508 compliance : https : //www.section508.gov/ , The bootloader takes this into consideration. HOWEVER, at The use of .sr-onlyIS not to Needs All that taken BE INTO Consideration for the Compliance 508. However, .sr-onlyuse .sr-onlyis not considered to meet all 508 compliance. You have the use of color, size of fonts, accessibility via navigation, descriptors, use of aria and so much more. You can use color, font size , accessibility through navigation, descriptors, use aria and so on.

AS for But .sr-only- at The CSS Actually the What does do? But as .sr-only-CSS actually is doing what? Several Slightly Different variants are there of Used for The CSS .sr-only. .sr-onlyFor .sr-onlya CSS several slightly different variants. One of the few I use is below: One of the few methods I use is as follows:

.sr-only {
    position: absolute;
    margin: -1px 0 0 -1px;
    padding: 0;
    display: block;
    width: 1px;
    height: 1px;
    font-size: 1px;
    line-height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
    outline: 0;
    }

The above CSS hides content in desktop and mobile browsers wrapped with this class, but is seen by a screen reader like JAWS: http://www.freedomscientific.com/Products/Blindness/JAWS . The above CSS is on the desktop of this type of packaging and mobile browsers hidden content, but you can see through like JAWS screen reader: HTTP : //www.freedomscientific.com/Products/Blindness/JAWS . Example markup is as follows: Example markup is as follows :

<a href="#" target="_blank">
    Click to Open Site
    <span class="sr-only">This is an external link</span>
</a>

Additionally, if a DOM element has a width and height of 0, the element is not seen by the DOM. In addition, if the width and height of the DOM element is 0, the DOM cannot see the element. This is why the above CSS uses width: 1px; height: 1px; this is above CSS uses width: 1px; height: 1px; width: 1px; height: 1px; . . A using By display: noneand Setting your CSS to height: 0and width: 0, at The Element at The IS not Seen by the DOM and IS THUS Problematic. By using display: noneand set CSS height: 0and width: 0, DOM can not see that element, and therefore there is a problem. The above CSS using width: 1px; height: 1px; the above CSS uses width: 1px; height: 1px; width: 1px; height: 1px; IS All you not to do the make at The Invisible Content to Desktop and Mobile browsers (the without overflow: hidden, your Content Would Still Show at The Screen ON), and visible to Screen Readers. Not the desktop and mobile browsers Can't see all the operations overflow: hiddenof the content (no , your content will still be displayed on the screen) and make the screen reader visible. Hiding the content from desktop and mobile browsers is done by adding an offset from width: 1pxand height: 1pxpreviously mentioned by using: The way to hide the content in desktop and mobile browsers is to use the previously mentioned width: 1pxand height: 1pxadd the offset:

position: absolute;
margin: -1px 0 0 -1px; 
overflow: hidden;

Lastly, to have a very good idea of ​​what a screen reader sees and relays to its impaired user, turn off page styling for your browser. Finally, to have a good understanding of what the screen reader will see and relay it to the Disabled users, please close the page style of the browser. For Firefox, you can do this by going to: For Firefox, you can do the following:

View > Page Style > No Style

I hope the information I provided here is of further use to someone in addition to the other responses. Hope that the information I provide here is useful to someone in addition to other responses .

Published 0 original articles · praised 75 · 560,000 views +

Guess you like

Origin blog.csdn.net/w36680130/article/details/105468030