@@ -60,6 +60,8 @@ include ../_util-fns
60
60
61
61
So without further ado, let us see how easy it is to get big accessibility gains in our applications!
62
62
63
+ **Feel free to follow along in this [live example](/resources/live-examples/cb-a11y/ts/plnkr.html)**.
64
+
63
65
.l-main-section
64
66
:marked
65
67
## Important note on styling in this chapter
@@ -352,6 +354,41 @@ code-example(language="html" escape="html" format="linenums").
352
354
</div >
353
355
</a11y-input-explicit >
354
356
357
+ :marked
358
+ ### Hidden labels
359
+
360
+ Sometimes, the design of your page makes more send without a visible label. Think about `search` fields. Do you have
361
+ to provide a visual label for each one?
362
+
363
+ The answer is no. But does that mean we get away with not labelling the field at all?
364
+
365
+ Once again the answer is no.
366
+
367
+ So how do we solve it?
368
+
369
+ We can either use an `explicitly labelled` input and hide the label with style, or we can use the `aria-label`, which
370
+ is an `ARIA Property`.
371
+
372
+ **NOTE:**: We cannot hide the label using the `display` css property. Hidden fields are also hidden to assistive
373
+ technologies so we have to use some css magic to either position the label outside of the visible page or
374
+ shrinking it right down to be absolutely minute. We wont see it but screen readers will still find it and read it while
375
+ still linking it to the correct input via the `for / id' linkup.
376
+
377
+ So why don't we create a component showing off both, and use the internal component styles to hide the label.
378
+
379
+ + 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' )
380
+
381
+ :marked
382
+ Which can then be used as:
383
+
384
+ + makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html' ,'cb-a11y-form-controls-hidden-labels-usage' )
385
+
386
+ :marked
387
+ The way the label is rendered int he final `HTML` is no secret to us anymore, but when you inspect the second input,
388
+ you will see that an `aria-label` attribute has been added to the input. Simplified:
389
+
390
+ code-example( language ="html" escape ="html" format ="linenums" ) .
391
+ <input aria-label =" Filter:" >
355
392
356
393
.l-main-section
357
394
<a id =" keyboard-shortcuts" ></a >
0 commit comments