@@ -138,43 +138,49 @@ include ../_util-fns
138
138
You will see the `ng-content` tag making its appearance a lot in the examples. This is because we are making use
139
139
of `Content Projection` to load content into the templates of our components.
140
140
141
- :marked
142
- ### Implicit labelling
141
+ .l-sub-section
142
+ :marked
143
+ It is very important to note that a `LABEL` element can describe one and only form input element. You cannot
144
+ label multiple form fields with one label. We will look at ways to do this with `ARIA` later.
143
145
144
- Firstly we will look at the absolute easiest way to furnish your form controls with accessible labels, and that is
145
- with a technique called `implicit labelling`.
146
+ .l-sub-section
147
+ :marked
148
+ And finally the label text position matters. For `inputs`, `textareas` and `selects`, the label text precedes
149
+ the element. Whilst for `checkboxes` and `radionbuttons` the text should follow the element in the flow.
146
150
147
- With this technique you get all the benefits of `a11y` for your controls by simply writing your `HTML` in a specific way.
151
+ :marked
152
+ ### Implicit labelling
148
153
149
- With this writing style you simply wrap the `HTML` element inside a label tag and you are done. There is no need to
150
- generate or suppply field id's as you will see with the other methods .
154
+ 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` .
151
156
152
- Implicit labelling is done as follows :
157
+ ` Implicit labelling` is done like this :
153
158
154
159
code-example( language ="html" escape ="html" ) .
155
160
<label >label text
156
161
<input >
157
162
</label >
158
163
159
164
:marked
160
- Of course, here the `INPUT` element can be any native `HTML` form element.
165
+ Easy hey? Of course, here the `INPUT` element can be any native `HTML` form element.
161
166
162
- Let us see how we would write the commonly used native `HTML` form elements in our Angular 2 components.
167
+ Let us now explore how we can use `implicit labelling` to decorate the commonly used native `HTML` form elements
168
+ in our Angular 2 components.
163
169
164
170
:marked
165
171
#### Inputs
166
172
167
- Your component template:
173
+ Component template:
168
174
169
175
+ makeExample('cb-a11y/ts/app/form-controls/a11y-input.component.html' )
170
176
171
177
:marked
172
- Used as :
178
+ User writes :
173
179
174
180
+ makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html' ,'cb-a11y-form-controls-input-usage' )
175
181
176
182
:marked
177
- Which is then rendered as :
183
+ Rendered out :
178
184
179
185
code-example( language ="html" escape ="html" format ="linenums" ) .
180
186
<a11y-input >
@@ -189,17 +195,17 @@ code-example(language="html" escape="html" format="linenums").
189
195
:marked
190
196
#### Textareas
191
197
192
- Your component template:
198
+ Component template:
193
199
194
200
+ makeExample('cb-a11y/ts/app/form-controls/a11y-textarea.component.html' )
195
201
196
202
:marked
197
- Used as :
203
+ User writes :
198
204
199
205
+ makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html' ,'cb-a11y-form-controls-textarea-usage' )
200
206
201
207
:marked
202
- Which is then rendered as :
208
+ Rendered out :
203
209
204
210
code-example( language ="html" escape ="html" format ="linenums" ) .
205
211
<a11y-textarea >
@@ -213,17 +219,17 @@ code-example(language="html" escape="html" format="linenums").
213
219
:marked
214
220
#### Checkboxes
215
221
216
- Your component template:
222
+ Component template:
217
223
218
224
+ makeExample('cb-a11y/ts/app/form-controls/a11y-checkboxes.component.html' )
219
225
220
226
:marked
221
- Used as :
227
+ User writes :
222
228
223
229
+ makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html' ,'cb-a11y-form-controls-checkboxes-usage' )
224
230
225
231
:marked
226
- Which is then rendered as :
232
+ Rendered out :
227
233
228
234
code-example( language ="html" escape ="html" format ="linenums" ) .
229
235
<a11y-checkboxes >
@@ -261,17 +267,17 @@ code-example(language="html" escape="html" format="linenums").
261
267
:marked
262
268
#### Radiobuttons
263
269
264
- Your component template:
270
+ Component template:
265
271
266
272
+ makeExample('cb-a11y/ts/app/form-controls/a11y-radiobuttons.component.html' )
267
273
268
274
:marked
269
- Used as :
275
+ User writes :
270
276
271
277
+ makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html' ,'cb-a11y-form-controls-radiobuttons-usage' )
272
278
273
279
:marked
274
- Which is then rendered as :
280
+ Rendered out :
275
281
276
282
code-example( language ="html" escape ="html" format ="linenums" ) .
277
283
<a11y-radiobuttons >
@@ -309,17 +315,17 @@ code-example(language="html" escape="html" format="linenums").
309
315
:marked
310
316
#### Select lists
311
317
312
- Your component template:
318
+ Component template:
313
319
314
320
+ makeExample('cb-a11y/ts/app/form-controls/a11y-select.component.html' )
315
321
316
322
:marked
317
- Used as :
323
+ User writes :
318
324
319
325
+ makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html' ,'cb-a11y-form-controls-select-usage' )
320
326
321
327
:marked
322
- Which is then rendered as :
328
+ Rendered out :
323
329
324
330
code-example( language ="html" escape ="html" format ="linenums" ) .
325
331
<a11y-select >
@@ -355,17 +361,17 @@ code-example(language="html" escape="html" format="linenums").
355
361
**NOTE:** In the example code we are generating `GUID's` for id's to ensure that they are unique. You can use your
356
362
own method to do this, as long as every page id is unique.
357
363
358
- Your component template:
364
+ Component template:
359
365
360
366
+ makeExample('cb-a11y/ts/app/form-controls/a11y-input-explicit.component.html' )
361
367
362
368
:marked
363
- Used as :
369
+ User writes :
364
370
365
371
+ makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html' ,'cb-a11y-form-controls-input-explicit-usage' )
366
372
367
373
:marked
368
- Which is then rendered as :
374
+ Rendered out :
369
375
370
376
code-example( language ="html" escape ="html" format ="linenums" ) .
371
377
<a11y-input-explicit >
0 commit comments