aboutsummaryrefslogtreecommitdiff
path: root/css.html
diff options
context:
space:
mode:
authoradamjacobbecker <[email protected]>2013-08-06 21:25:36 -0700
committeradamjacobbecker <[email protected]>2013-08-06 21:58:09 -0700
commita8d95d4721e714a7e1d683e14e997faa5ccddaff (patch)
tree13b2659725668e0dde39f1f15810a8303443aa16 /css.html
parentd1e712d84882953b7d2a43a8e70aa3b976da5fcd (diff)
downloadbootstrap-a8d95d4721e714a7e1d683e14e997faa5ccddaff.tar.xz
bootstrap-a8d95d4721e714a7e1d683e14e997faa5ccddaff.zip
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.
Diffstat (limited to 'css.html')
-rw-r--r--css.html22
1 files changed, 18 insertions, 4 deletions
diff --git a/css.html b/css.html
index 26b8f1d3f..17e1deae6 100644
--- a/css.html
+++ b/css.html
@@ -1300,9 +1300,15 @@ For example, <code>&lt;section&gt;</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>&lt;section&gt;</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
@@ -1986,6 +1994,12 @@ For example, <code>&lt;section&gt;</code> should be wrapped as inline.
.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>
<!-- Responsive utilities