aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick H. Lauke <[email protected]>2015-12-23 22:09:33 +0000
committerPatrick H. Lauke <[email protected]>2015-12-24 10:08:29 +0000
commit0fe8f920b76fcf523bfa08bb43eac4f487858c12 (patch)
tree2ee752948507ec8b7ae6b94c84f6c8a0f980ae02
parent86c0520613d37beb2b7f592e72806c4b3152d26e (diff)
downloadbootstrap-0fe8f920b76fcf523bfa08bb43eac4f487858c12.tar.xz
bootstrap-0fe8f920b76fcf523bfa08bb43eac4f487858c12.zip
Docs: reintroduce aria-describedby advice for help text
Based on v3 http://getbootstrap.com/css/#forms-help-text, adapted to make examples more "real life"
-rw-r--r--docs/components/forms.md24
1 files changed, 19 insertions, 5 deletions
diff --git a/docs/components/forms.md b/docs/components/forms.md
index f40904f8e..ee001a473 100644
--- a/docs/components/forms.md
+++ b/docs/components/forms.md
@@ -517,19 +517,33 @@ Wrap inputs in grid columns, or any custom parent element, to easily enforce des
No official help text classes exist in Bootstrap 4 (previously we had `.help-block` in v3), but thanks to our utility classes like `.text-muted`, you can create much more flexible help text as you need it.
+{% callout warning %}
+#### Associating help text with form controls
+
+Help text should be explicitly associated with the form control it relates to using the `aria-describedby` attribute. This will ensure that assistive technologies – such as screen readers – will announce this help text when the user focuses or enters the control.
+{% endcallout %}
+
Inline text can use any typical inline HTML element (be it a `<small>`, `<span>`, or something else).
{% example html %}
-<small class="text-muted">
- Some inline text with a small tag looks like this.
-</small>
+<form class="form-inline">
+ <div class="form-group">
+ <label for="inputPassword4">Password</label>
+ <input type="password" id="inputPassword4" class="form-control" aria-describedby="passwordHelpInline">
+ <small id="passwordHelpInline" class="text-muted">
+ Must be 8-20 characters long.
+ </small>
+ </div>
+</form>
{% endexample %}
Block help text—for below inputs or for longer lines of help text—can be easily achieved with a `<p>`.
{% example html %}
-<p class="text-muted">
- A block of help text that breaks onto a new line and may extend beyond one line.
+<label for="inputPassword5">Password</label>
+<input type="password" id="inputPassword5" class="form-control" aria-describedby="passwordHelpBlock">
+<p id="passwordHelpBlock" class="text-muted">
+ Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters or emoji.
</p>
{% endexample %}