mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-05-21 13:24:08 +03:00
Improve accessibility (Section 508, WCAG)
This PR significantly improves Bootstrap's accessibility for users of assistive technology, such as screen readers. Some of the these changes add additional markup to the source examples, but we believe that the sacrifice in readability is worth achieving more widespread usage of accessibility best-practices. What was done - Added lots of [WAI-ARIA attributes](http://www.w3.org/WAI/intro/aria) - Added `.sr-only` helper class, that is only readable by screen readers (and invisible for all other users). This lets us - make progress bars and paginations accessible to screen reading users. - Advised users to always use label elements. For inline forms, they can hide them with `.sr-only` - Added 'Skip navigation' link - Added "Accessibility" section to getting-started.html. What *wasn't* done - Contrast issues (twbs#3572) - Tooltips (twbs#8469) - Documentation re: usage of icons, since they now live in a separate repo Major props to all that contributed: @bensheldon, @jasonlally, @criscristina, and @louh. Feel free to chime in, guys, if I've left anything out.
This commit is contained in:
@@ -1300,9 +1300,15 @@ For example, <code><section></code> should be wrapped as inline.
|
||||
<h4>Requires custom widths</h4>
|
||||
<p>Inputs, selects, and textareas are 100% wide by default in Bootstrap. To use the inline form, you'll have to set a width on the form controls used within.</p>
|
||||
</div>
|
||||
<div class="bs-callout bs-callout-danger">
|
||||
<h4>Always add labels</h4>
|
||||
<p>Screen readers will have trouble with your forms if you don't include a label for every input. For these inline forms, you can hide the labels using the <code>.sr-only</code> class.</p>
|
||||
</div>
|
||||
<form class="bs-example form-inline">
|
||||
<input type="text" class="form-control" placeholder="Email">
|
||||
<input type="password" class="form-control" placeholder="Password">
|
||||
<label class="sr-only" for="exampleInputEmail">Email address</label>
|
||||
<input type="text" class="form-control" id="exampleInputEmail" placeholder="Enter email">
|
||||
<label class="sr-only" for="exampleInputPassword">Password</label>
|
||||
<input type="password" class="form-control" id="exampleInputPassword" placeholder="Password">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox"> Remember me
|
||||
@@ -1312,8 +1318,10 @@ For example, <code><section></code> should be wrapped as inline.
|
||||
</form><!-- /example -->
|
||||
{% highlight html %}
|
||||
<form class="form-inline">
|
||||
<input type="text" class="form-control" placeholder="Email">
|
||||
<input type="password" class="form-control" placeholder="Password">
|
||||
<label class="sr-only" for="exampleInputEmail">Email address</label>
|
||||
<input type="text" class="form-control" id="exampleInputEmail" placeholder="Enter email">
|
||||
<label class="sr-only" for="exampleInputPassword">Password</label>
|
||||
<input type="password" class="form-control" id="exampleInputPassword" placeholder="Password">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox"> Remember me
|
||||
@@ -1985,6 +1993,12 @@ For example, <code><section></code> should be wrapped as inline.
|
||||
.element {
|
||||
.clearfix();
|
||||
}
|
||||
{% endhighlight %}
|
||||
|
||||
<h3>.sr-only</h3>
|
||||
<p>Hide an element to all users <em>except</em> screen readers. Necessary for following <a href="{{ page.base_url }}getting-started#accessibility">accessibility best practices</a>.</p>
|
||||
{% highlight html %}
|
||||
<a class="sr-only" href="#content">Skip to content</a>
|
||||
{% endhighlight %}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user