]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Accessibility tweaks and explanation for glyphicons
authorPatrick H. Lauke <redux@splintered.co.uk>
Tue, 4 Nov 2014 10:39:54 +0000 (10:39 +0000)
committerPatrick H. Lauke <redux@splintered.co.uk>
Mon, 10 Nov 2014 08:55:58 +0000 (08:55 +0000)
- add aria-hidden="true" to avoid SRs unintentionally reading out the
Unicode character (see
http://www.filamentgroup.com/lab/bulletproof_icon_fonts.html)
- callout with advice on accessible icon usage
- replaced sr-only text in examples with (in the case of button) cleaner
aria-label
- additional example of icon used to convey meaning (in a
non-interactive control)

docs/_includes/components/glyphicons.html

index c614103c636fb4ea806416c96fae82f1951b55f3..b5f5178df36eadad128e4a09905e4722c75556ea 100644 (file)
@@ -7,7 +7,7 @@
     <ul class="bs-glyphicons-list">
       {% for iconClassName in site.data.glyphicons %}
         <li>
-          <span class="glyphicon {{ iconClassName }}"></span>
+          <span class="glyphicon {{ iconClassName }}" aria-hidden="true"></span>
           <span class="glyphicon-class">glyphicon {{ iconClassName }}</span>
         </li>
       {% endfor %}
     </ul>
     <p>Use whatever option best suits your specific development setup.</p>
   </div>
+  <div class="bs-callout bs-callout-warning">
+    <h4>Accessible icons</h4>
+    <p>Modern versions of assistive technologies will announce CSS generated content, as well as specific Unicode characters. To avoid unintended and confusing output in screen readers (particularly when icons are used purely for decoration), we hide them with the <code>aria-hidden="true"</code> attribute.</p>
+    <p>If you're using an icon to convey meaning (rather than only as a decorative element), ensure that this meaning is also conveyed to assistive technologies – for instance, include additional content, visually hidden with the <code>.sr-only</code> class.</p>
+    <p>If you're creating controls with no other text (such as a <code>&lt;button&gt;</code> that only contains an icon), you should always provide alternative content to identify the purpose of the control, so that it will make sense to users of assistive technologies. In this case, you could add an <code>aria-label</code> attribute on the control itself.</p>
+  </div>
 {% highlight html %}
-<span class="glyphicon glyphicon-search"></span>
+<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
 {% endhighlight %}
 
 
   <div class="bs-example">
     <div class="btn-toolbar" role="toolbar">
       <div class="btn-group">
-        <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-align-left"></span> <span class="sr-only">Left Align</span></button>
-        <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-align-center"></span> <span class="sr-only">Center Align</span></button>
-        <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-align-right"></span> <span class="sr-only">Right Align</span></button>
-        <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-align-justify"></span> <span class="sr-only">Justify</span></button>
+        <button type="button" class="btn btn-default" aria-label="Left Align"><span class="glyphicon glyphicon-align-left" aria-hidden="true"></span></button>
+        <button type="button" class="btn btn-default" aria-label="Center Align"><span class="glyphicon glyphicon-align-center" aria-hidden="true"></span></button>
+        <button type="button" class="btn btn-default" aria-label="Right Align"><span class="glyphicon glyphicon-align-right" aria-hidden="true"></span></button>
+        <button type="button" class="btn btn-default" aria-label="Justify"><span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span></button>
       </div>
     </div>
     <div class="btn-toolbar" role="toolbar">
-      <button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-star"></span> Star</button>
-      <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-star"></span> Star</button>
-      <button type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-star"></span> Star</button>
-      <button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-star"></span> Star</button>
+      <button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
+      <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
+      <button type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
+      <button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
     </div>
   </div>
 {% highlight html %}
+<button type="button" class="btn btn-default" aria-label="Left Align">
+  <span class="glyphicon glyphicon-align-left" aria-hidden="true"></span>
+</button>
+
 <button type="button" class="btn btn-default btn-lg">
-  <span class="glyphicon glyphicon-star"></span> Star
+  <span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star
 </button>
+{% endhighlight %}
+  <p>An icon used in an <a href="#alerts">alert</a> to convey that it's an error message, with additional <code>.sr-only</code> text to convey this hint to users of assistive technologies.</p>
+  <div class="bs-example">
+    <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>
+  </div>
+{% highlight html %}
+<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>
 {% endhighlight %}
 </div>