@@ -152,7 +152,7 @@ include ../_util-fns
152152 ### Implicit labelling
153153
154154 Firstly we will look at the absolute easiest, quickest way to furnish our form controls with accessible labels,
155- and that is with a pattern called `implicit labelling`.
155+ and that is with a syntax called `implicit labelling`.
156156
157157 `Implicit labelling` is done like this:
158158
@@ -162,7 +162,7 @@ code-example(language="html" escape="html").
162162 </label >
163163
164164:marked
165- Easy hey ? Of course, here the `INPUT` element can be any native `HTML` form element.
165+ Easy, isn't it ? Of course, here the `INPUT` element can be any native `HTML` form element.
166166
167167 Let us now explore how we can use `implicit labelling` to decorate the commonly used native `HTML` form elements
168168 in our Angular 2 components.
@@ -219,6 +219,12 @@ code-example(language="html" escape="html" format="linenums").
219219:marked
220220 #### Checkboxes
221221
222+ .l-sub-section
223+ :marked
224+ Because of the many `input` fields making up a `checkbox group`, the usual rule applies for each input but the
225+ entire group also needs labelled and this is done by using `fieldset` and `legend`.
226+
227+ :marked
222228 Component template:
223229
224230+ makeExample('cb-a11y/ts/app/form-controls/a11y-checkboxes.component.html' )
@@ -267,6 +273,11 @@ code-example(language="html" escape="html" format="linenums").
267273:marked
268274 #### Radiobuttons
269275
276+ .l-sub-section
277+ :marked
278+ As with the `checkbox group`, a `radiobutton group`, is also labelled using `fieldset` and `legend`.
279+
280+ :marked
270281 Component template:
271282
272283+ makeExample('cb-a11y/ts/app/form-controls/a11y-radiobuttons.component.html' )
@@ -347,20 +358,24 @@ code-example(language="html" escape="html" format="linenums").
347358 you need to write the input outside the lable for positioning or styling purposes. Or maybe your elements are
348359 already furnished with id's.
349360
350- As alternative you can also use the `explicit labelling` syntax. For this syntax you are required to add an `id` to
351- the `HTML` form element to connect the label up via a `for / id` pairing [The `for` attribute of the label has to
352- contain the `id` of the input being labelled].
361+ As an alternative, you can also use the `explicit labelling` syntax. For this syntax you are required to add an `id` to
362+ the `HTML` form element. This is then connected up up via a `for / id` pairing * [The `for` attribute of the label has to
363+ match the `id` of the element being labelled]* .
353364
354- This is also the reason why `implicit labelling` could come in very useful with reusable Angular 2 components.
355- Remember that an `id` should be unique on a page, and any component where `explicit labelling` is used, will need
356- a way to add unique id's to the elements, unless it is certain that the component will only be used once per page.
365+ This is also the reason why `implicit labelling` could be more useful with reusable Angular 2 components.
366+ Remember that an `id` should be unique on a page. This means that any component with `explicit labelling` in its
367+ template, will need a way ensure that its elements are uniquely labelled, unless it is certain that the component
368+ will only be used once per page.
357369
358- This time we will only look at adding an `explicit label` to an `INPUT`. The examples under the `implicit labelling`
359- section can then easily be adjusted to use this pattern .
370+ As an example, we will only look at adding an `explicit label` to an `INPUT`. The examples under the `implicit labelling`
371+ section can then easily be adjusted to use this syntax .
360372
361- **NOTE:** In the example code we are generating `GUID's` for id's to ensure that they are unique. You can use your
362- own method to do this, as long as every page id is unique.
373+ .l-sub-section
374+ :marked
375+ In the example application code we are generating `GUID's` for id's to ensure that they are unique. You can use your
376+ own method to do this, as long as every id on a page is unique.
363377
378+ :marked
364379 Component template:
365380
366381+ makeExample('cb-a11y/ts/app/form-controls/a11y-input-explicit.component.html' )
@@ -382,15 +397,15 @@ code-example(language="html" escape="html" format="linenums").
382397 < input class="form-control"
383398 id="c90c7f99-330e-4723-bfa8-9ab72a4bd435">
384399 </div >
385- </a11y-input-explicit >
400+ </a11y-input-explicit >
386401
387402:marked
388403 ### Hidden labels
389404
390- Sometimes, the design of your page makes more send without a visible label. Think about `search` fields. Do you have
405+ Sometimes, the design of your page makes more sense without a visible label. Think about `search` fields. Do you have
391406 to provide a visual label for each one?
392407
393- The answer is no. But does that mean we get away with not labelling the field at all?
408+ The answer is no. But does that mean we get away with not labelling those fields at all?
394409
395410 Once again the answer is no.
396411
@@ -399,12 +414,16 @@ code-example(language="html" escape="html" format="linenums").
399414 We can either use an `explicitly labelled` input and hide the label with style, or we can use the `aria-label`, which
400415 is an `ARIA Property`.
401416
402- **NOTE:**: We cannot hide the label using the `display` css property. Hidden fields are also hidden to assistive
403- technologies so we have to use some css magic to either position the label outside of the visible page or
404- shrinking it right down to be absolutely minute. We wont see it but screen readers will still find it and read it while
405- still linking it to the correct input via the `for / id' linkup.
417+ .l-sub-section
418+ :marked
419+ We cannot hide the label using the `display` css property. Hidden fields are also hidden to assistive
420+ technologies so we have to use some css magic to either position the label outside of the visible page or
421+ shrinking it right down to be absolutely minute. We wont see it but screen readers will still find it and read it while
422+ still linking it to the correct input via the `for / id` linkup. The following example contains such a
423+ `visually hidden` style.
406424
407- So why don't we create a component showing off both, and use the internal component styles to hide the label.
425+ :marked
426+ Let us create a component showing off both, and use the internal component styles to hide the label.
408427
409428+ makeTabs('cb-a11y/ts/app/form-controls/a11y-hidden-labels.component.html, cb-a11y/ts/app/form-controls/a11y-hidden-labels.component.ts, cb-a11y/ts/app/form-controls/a11y-hidden-labels.component.css' , null , 'a11y-hidden-labels.component.html,a11y-hidden-labels.component.ts,a11y-hidden-labels.component.css' )
410429
@@ -420,6 +439,10 @@ code-example(language="html" escape="html" format="linenums").
420439code-example( language ="html" escape ="html" format ="linenums" ) .
421440 <input aria-label =" Filter:" >
422441
442+ :marked
443+ This `aria-label` attribute serves the same purpose as our `LABEL` tags above and will tell screen readers what
444+ the field is called.
445+
423446.l-main-section
424447<a id =" keyboard-shortcuts" ></a >
425448:marked
0 commit comments