Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 3ec7e43

Browse files
committed
doc(cb-a11y): Labelling form controls: content
1 parent 42fcfbe commit 3ec7e43

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<nav role="navigation">
22
<ol>
33
<li>
4-
<a href="" [routerLink]="['FormControls']"><h2>Accessible form control labels</h2></a>
4+
<a [routerLink]="['FormControls']"><h2>Accessible form control labels</h2></a>
55
</li>
66
</ol>
7-
</nav>
7+
</nav>

public/docs/ts/latest/cookbook/a11y.jade

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ include ../_util-fns
3636

3737
.l-sub-section
3838
:marked
39-
`ARIA`, or `Accessible Rich Internet Applications` refers to bringing `a11y` concepts into
39+
`ARIA`, or `Accessible Rich Internet Applications` refers to a standard set of attributes for adding accessibility
40+
information to `HTML` and `SVG`. This allows us to bring `a11y` concepts into
4041
internet applications like those we are building with Angular&nbsp;2.
4142

4243
:marked
@@ -112,7 +113,7 @@ include ../_util-fns
112113

113114
[Component that knows its own role](#component-roles)
114115

115-
[Managing focus](#managin-focus)
116+
[Managing focus](#managing-focus)
116117

117118
.l-sub-section
118119
:marked
@@ -134,7 +135,7 @@ include ../_util-fns
134135
A nightmare right? Users will leave so fast the bouncerate counter will be able to power a small town it will be
135136
spinning *THAT* fast.
136137

137-
We can avoid this from ever happening by simply adding a label for each field. Generaly this is not out problem,
138+
We can avoid this from ever happening by simply adding a label for each field. Generally this is not our problem,
138139
however the users of our website may not always be able to see or recognise these labels without assistance.
139140

140141
For this reason it is not only important to visually mark any form component, or as they are sometimes called,
@@ -247,7 +248,7 @@ code-example(language="html" escape="html").
247248
The answer is no. But does that mean we get away with not labelling those fields at all?
248249

249250
Once again the answer is no.
250-
251+
251252
So how do we solve it?
252253

253254
We can either use an `explicitly labelled` input and hide the label with style, or we can use the `aria-label`, which
@@ -283,9 +284,33 @@ code-example(language="html" escape="html").
283284
.l-sub-section
284285
:marked
285286
So why not simply always use `aria-label`? This is because adding the `label` element not only provides the visual
286-
label, but linking a `label` to a `form control` also means that clicking on the `label` will select the
287+
label, but linking a `label` to a `native form control` also means that clicking on the `label` will select the
287288
`form control` itself. This touches on another area of `a11y`, as this also assists users with motor disabilites
288289
to more easily select them.
290+
291+
:marked
292+
Lets have a look at a quick comparison between using this method as opposed to not taking `a11y` into account at all.
293+
294+
Here is what happens if we have an `input` for filtering criteria that does not take any `a11y` into account. We will
295+
use the accessibility tools in the newest development version of `Chrome`, although you can use one of various internal
296+
and external web browser tools to test accessibility. This is the information that assistive technologies will
297+
use when reading our field out:
298+
299+
figure.image-display
300+
img(src="/resources/images/cookbooks/a11y/invisible-label-input-not-labelled.png" alt="Input with invisible label not labelled correctly")
301+
302+
:marked
303+
We can clearly see that the only description a user with a screen reader will get is **Enter a value**. What value?
304+
305+
Just imagine if there are more than one input on the same page with the same placeholder. Utter chaos!
306+
307+
Now lets put our `a11y` info back and look at the same input again:
308+
309+
figure.image-display
310+
img(src="/resources/images/cookbooks/a11y/invisible-label-input-labelled.png" alt="Input with invisible label labelled correctly")
311+
312+
:marked
313+
Immediately it is clear what this `input` field is and what the user is supposed to enter in it!
289314

290315
:marked
291316
### Labelling custom form controls
@@ -296,7 +321,7 @@ code-example(language="html" escape="html").
296321

297322
How would you go about making these custom form controls accessible?
298323

299-
Fear not, there is a way! We introduce the next addition to our `ARIA` toolkit, and that is `aria-labeledby`.
324+
Fear not, there is a way! We introduce the next addition to our `ARIA` toolkit, and that is `aria-labelledby`.
300325

301326
Why do we need this? Because the native `a11y` function of the `label` element is only recognised when used with
302327
native `HTML` form control elements such as `input` and `textarea`. To label anything else, like a `div` or a
Loading
Loading

0 commit comments

Comments
 (0)