mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-18 15:54:26 +01:00
Add explicit aria-label to placeholder-only inputs
While `placeholder` is nominally valid per spec http://rawgit.com/w3c/html-api-map/master/index.html#accessible-name-and-description-calculation it is inelegant, a fallback, and not supported in ios/safari/voiceover and android/chrome/talkback, to name a few combinations `aria-describedby` is also not really the right tool for providing a name/label equivalent, so remove that from the list of possible alternative methods / clarify how it can be used
This commit is contained in:
commit
0af28c26ec
@ -59,7 +59,7 @@ Feel free to mix input groups with button groups in your toolbars. Similar to th
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" id="btnGroupAddon">@</span>
|
||||
<input type="text" class="form-control" placeholder="Input group example" aria-describedby="btnGroupAddon">
|
||||
<input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -72,7 +72,7 @@ Feel free to mix input groups with button groups in your toolbars. Similar to th
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" id="btnGroupAddon2">@</span>
|
||||
<input type="text" class="form-control" placeholder="Input group example" aria-describedby="btnGroupAddon2">
|
||||
<input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon2">
|
||||
</div>
|
||||
</div>
|
||||
{% endexample %}
|
||||
|
@ -19,11 +19,11 @@ Place one add-on or button on either side of an input. You may also place one on
|
||||
{% example html %}
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" id="basic-addon1">@</span>
|
||||
<input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
|
||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
|
||||
</div>
|
||||
<br>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Recipient's username" aria-describedby="basic-addon2">
|
||||
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
|
||||
<span class="input-group-addon" id="basic-addon2">@example.com</span>
|
||||
</div>
|
||||
<br>
|
||||
@ -53,12 +53,12 @@ Add the relative form sizing classes to the `.input-group` itself and contents w
|
||||
{% example html %}
|
||||
<div class="input-group input-group-lg">
|
||||
<span class="input-group-addon" id="sizing-addon1">@</span>
|
||||
<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon1">
|
||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="sizing-addon1">
|
||||
</div>
|
||||
<br>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" id="sizing-addon2">@</span>
|
||||
<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon2">
|
||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="sizing-addon2">
|
||||
</div>
|
||||
{% endexample %}
|
||||
|
||||
@ -124,12 +124,12 @@ Buttons in input groups must wrapped in a `.input-group-btn` for proper alignmen
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-secondary" type="button">Go!</button>
|
||||
</span>
|
||||
<input type="text" class="form-control" placeholder="Search for...">
|
||||
<input type="text" class="form-control" placeholder="Search for..." aria-label="Search for...">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Search for...">
|
||||
<input type="text" class="form-control" placeholder="Search for..." aria-label="Search for...>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-secondary" type="button">Go!</button>
|
||||
</span>
|
||||
@ -143,7 +143,7 @@ Buttons in input groups must wrapped in a `.input-group-btn` for proper alignmen
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-secondary" type="button">Hate it</button>
|
||||
</span>
|
||||
<input type="text" class="form-control" placeholder="Product name">
|
||||
<input type="text" class="form-control" placeholder="Product name" aria-label="Product name">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-secondary" type="button">Love it</button>
|
||||
</span>
|
||||
@ -240,4 +240,4 @@ Buttons in input groups must wrapped in a `.input-group-btn` for proper alignmen
|
||||
|
||||
Screen readers will have trouble with your forms if you don't include a label for every input. For these input groups, ensure that any additional label or functionality is conveyed to assistive technologies.
|
||||
|
||||
The exact technique to be used (`<label>` elements hidden using the `.sr-only` class, or use of the `aria-label`, `aria-labelledby`, `aria-describedby`, `title` or `placeholder` attribute) and what additional information will need to be conveyed will vary depending on the exact type of interface widget you're implementing. The examples in this section provide a few suggested, case-specific approaches.
|
||||
The exact technique to be used (`<label>` elements hidden using the `.sr-only` class, or use of the `aria-label` and `aria-labelledby` attributes, possibly in combination with `aria-describedby`) and what additional information will need to be conveyed will vary depending on the exact type of interface widget you're implementing. The examples in this section provide a few suggested, case-specific approaches.
|
||||
|
@ -57,7 +57,7 @@ Here's an example of all the sub-components included in a responsive light-theme
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my-2 my-lg-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
@ -192,7 +192,7 @@ Place various form controls and components within a navbar with `.form-inline`.
|
||||
{% example html %}
|
||||
<nav class="navbar navbar-light bg-faded">
|
||||
<form class="form-inline">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</nav>
|
||||
@ -204,7 +204,7 @@ Align the contents of your inline forms with utilities as needed.
|
||||
<nav class="navbar navbar-light bg-faded justify-content-between">
|
||||
<a class="navbar-brand">Navbar</a>
|
||||
<form class="form-inline">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</nav>
|
||||
@ -217,7 +217,7 @@ Input groups work, too:
|
||||
<form class="form-inline">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" id="basic-addon1">@</span>
|
||||
<input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
|
||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
|
||||
</div>
|
||||
</form>
|
||||
</nav>
|
||||
@ -300,7 +300,7 @@ Theming the navbar has never been easier thanks to the combination of theming cl
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-info my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
@ -328,7 +328,7 @@ Theming the navbar has never been easier thanks to the combination of theming cl
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-secondary my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
@ -356,7 +356,7 @@ Theming the navbar has never been easier thanks to the combination of theming cl
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-primary my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
@ -458,7 +458,7 @@ With no `.navbar-brand` shown in lowest breakpoint:
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my-2 my-lg-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
@ -516,7 +516,7 @@ With a toggler on the left and brand name on the right:
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my-2 my-lg-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -35,7 +35,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline mt-2 mt-md-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -39,7 +39,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline mt-2 mt-md-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -45,7 +45,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my-2 my-lg-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -36,7 +36,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline mt-2 mt-md-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -36,7 +36,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline mt-2 mt-md-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -45,7 +45,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my-2 my-md-0">
|
||||
<input class="form-control" type="text" placeholder="Search">
|
||||
<input class="form-control" type="text" placeholder="Search" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</nav>
|
||||
@ -238,7 +238,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my-2 my-md-0">
|
||||
<input class="form-control" type="text" placeholder="Search">
|
||||
<input class="form-control" type="text" placeholder="Search" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -300,7 +300,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my-2 my-md-0">
|
||||
<input class="form-control" type="text" placeholder="Search">
|
||||
<input class="form-control" type="text" placeholder="Search" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</nav>
|
||||
|
@ -45,7 +45,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my-2 my-lg-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -45,7 +45,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my-2 my-lg-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -37,7 +37,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline mt-2 mt-md-0">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search">
|
||||
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user