Skip to content

Commit 255e5d6

Browse files
committed
Merge pull request twbs#15320 from patrickhlauke/docs-accessibility-tweaks
Docs accessibility tweaks: use ``aria-label`` for close ``<button>``, expand advice for ``<abbr>``, form control labels, make sidebar navigation a ``<nav>``
2 parents 08f3886 + 202f1f8 commit 255e5d6

File tree

7 files changed

+20
-22
lines changed

7 files changed

+20
-22
lines changed

docs/_includes/components/alerts.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ <h4>Requires JavaScript alert plugin</h4>
4040
</div>
4141
<div class="bs-example" data-example-id="dismissible-alert-css">
4242
<div class="alert alert-warning alert-dismissible" role="alert">
43-
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
43+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
4444
<strong>Warning!</strong> Better check yourself, you're not looking too good.
4545
</div>
4646
</div>
4747
{% highlight html %}
4848
<div class="alert alert-warning alert-dismissible" role="alert">
49-
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
49+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
5050
<strong>Warning!</strong> Better check yourself, you're not looking too good.
5151
</div>
5252
{% endhighlight %}

docs/_includes/components/navbar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ <h4>Mobile device caveats</h4>
208208

209209
<div class="bs-callout bs-callout-warning" id="callout-navbar-form-labels">
210210
<h4>Always add labels</h4>
211-
<p>Screen readers will have trouble with your forms if you don't include a label for every input. For these inline navbar forms, you can hide the labels using the <code>.sr-only</code> class.</p>
211+
<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. There are further alternative methods of providing a label for assistive technologies, such as the <code>aria-label</code>, <code>aria-labelledby</code> or <code>title</code> attribute. If none of these is present, screen readers may resort to using the <code>placeholder</code> attribute, if present, but note that use of <code>placeholder</code> as a replacement for other labelling methods is not advised.</p>
212212
</div>
213213

214214

docs/_includes/css/helpers.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ <h4>Conveying meaning to assistive technologies</h4>
5656
<h3 id="helper-classes-close">Close icon</h3>
5757
<p>Use the generic close icon for dismissing content like modals and alerts.</p>
5858
<div class="bs-example" data-example-id="close-icon">
59-
<p><button type="button" class="close"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button></p>
59+
<p><button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button></p>
6060
</div>
6161
{% highlight html %}
62-
<button type="button" class="close"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
62+
<button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>
6363
{% endhighlight %}
6464

6565

docs/_includes/css/type.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,9 @@ <h2 id="type-transformation">Transformation classes</h2>
220220

221221
<!-- Abbreviations -->
222222
<h2 id="type-abbreviations">Abbreviations</h2>
223-
<p>Stylized implementation of HTML's <code>&lt;abbr&gt;</code> element for abbreviations and acronyms to show the expanded version on hover. Abbreviations with a <code>title</code> attribute have a light dotted bottom border and a help cursor on hover, providing additional context on hover.</p>
223+
<p>Stylized implementation of HTML's <code>&lt;abbr&gt;</code> element for abbreviations and acronyms to show the expanded version on hover. Abbreviations with a <code>title</code> attribute have a light dotted bottom border and a help cursor on hover, providing additional context on hover and to users of assistive technologies.</p>
224224

225225
<h3>Basic abbreviation</h3>
226-
<p>For expanded text on long hover of an abbreviation, include the <code>title</code> attribute with the <code>&lt;abbr&gt;</code> element.</p>
227226
<div class="bs-example" data-example-id="simple-abbr">
228227
<p>An abbreviation of the word attribute is <abbr title="attribute">attr</abbr>.</p>
229228
</div>

docs/_includes/js/alerts.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ <h2 id="alerts-examples">Example alerts</h2>
66
<p>When using a <code>.close</code> button, it must be the first child of the <code>.alert-dismissible</code> and no text content may come before it in the markup.</p>
77
<div class="bs-example bs-example-standalone" data-example-id="dismissible-alert-js">
88
<div class="alert alert-warning alert-dismissible fade in" role="alert">
9-
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
9+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
1010
<strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
1111
</div>
1212

1313
<div class="alert alert-danger alert-dismissible fade in" role="alert">
14-
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
14+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
1515
<h4>Oh snap! You got an error!</h4>
1616
<p>Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.</p>
1717
<p>
@@ -27,9 +27,8 @@ <h2 id="alerts-usage">Usage</h2>
2727
<p>Just add <code>data-dismiss="alert"</code> to your close button to automatically give an alert close functionality. Closing an alert removes it from the DOM.</p>
2828

2929
{% highlight html %}
30-
<button type="button" class="close" data-dismiss="alert">
30+
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
3131
<span aria-hidden="true">&times;</span>
32-
<span class="sr-only">Close</span>
3332
</button>
3433
{% endhighlight %}
3534

docs/_includes/js/modal.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h3>Static example</h3>
3131
<div class="modal-dialog">
3232
<div class="modal-content">
3333
<div class="modal-header">
34-
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
34+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
3535
<h4 class="modal-title">Modal title</h4>
3636
</div>
3737
<div class="modal-body">
@@ -50,7 +50,7 @@ <h4 class="modal-title">Modal title</h4>
5050
<div class="modal-dialog">
5151
<div class="modal-content">
5252
<div class="modal-header">
53-
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
53+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
5454
<h4 class="modal-title">Modal title</h4>
5555
</div>
5656
<div class="modal-body">
@@ -73,7 +73,7 @@ <h3>Live demo</h3>
7373
<div class="modal-content">
7474

7575
<div class="modal-header">
76-
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
76+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
7777
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
7878
</div>
7979
<div class="modal-body">
@@ -124,7 +124,7 @@ <h4>Overflowing text to show scroll behavior</h4>
124124
<div class="modal-dialog">
125125
<div class="modal-content">
126126
<div class="modal-header">
127-
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
127+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
128128
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
129129
</div>
130130
<div class="modal-body">
@@ -186,7 +186,7 @@ <h2 id="modals-sizes">Optional sizes</h2>
186186
<div class="modal-content">
187187

188188
<div class="modal-header">
189-
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
189+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
190190
<h4 class="modal-title" id="myLargeModalLabel">Large modal</h4>
191191
</div>
192192
<div class="modal-body">
@@ -200,7 +200,7 @@ <h4 class="modal-title" id="myLargeModalLabel">Large modal</h4>
200200
<div class="modal-content">
201201

202202
<div class="modal-header">
203-
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
203+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
204204
<h4 class="modal-title" id="mySmallModalLabel">Small modal</h4>
205205
</div>
206206
<div class="modal-body">
@@ -230,7 +230,7 @@ <h2 id="modals-related-target">Varying modal content based on trigger button</h2
230230
<div class="modal-dialog">
231231
<div class="modal-content">
232232
<div class="modal-header">
233-
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
233+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
234234
<h4 class="modal-title" id="exampleModalLabel">New message</h4>
235235
</div>
236236
<div class="modal-body">
@@ -263,7 +263,7 @@ <h4 class="modal-title" id="exampleModalLabel">New message</h4>
263263
<div class="modal-dialog">
264264
<div class="modal-content">
265265
<div class="modal-header">
266-
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
266+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
267267
<h4 class="modal-title" id="exampleModalLabel">New message</h4>
268268
</div>
269269
<div class="modal-body">

docs/_layouts/default.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ <h1>{{ page.title }}</h1>
2626
{{ content }}
2727
</div>
2828
{% unless page.fullwidth == true %}
29-
<div class="col-md-3">
30-
<div class="bs-docs-sidebar hidden-print hidden-xs hidden-sm" role="complementary">
29+
<div class="col-md-3" role="complementary">
30+
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm">
3131
<ul class="nav bs-docs-sidenav">
3232
{% if page.slug == "getting-started" %}
3333
{% include nav/getting-started.html %}
@@ -53,7 +53,7 @@ <h1>{{ page.title }}</h1>
5353
Preview theme
5454
</a>
5555
{% endif %}
56-
</div>
56+
</nav>
5757
</div>
5858
{% endunless %}
5959
</div>

0 commit comments

Comments
 (0)