diff --git a/techniques/aria/ARIA14.html b/techniques/aria/ARIA14.html index 68e03b1099..46f3e0d157 100644 --- a/techniques/aria/ARIA14.html +++ b/techniques/aria/ARIA14.html @@ -1,63 +1,96 @@ -Using aria-label to provide an invisible label where a visible label cannot be used

Using aria-label to provide an invisible label where a visible label cannot be used

ID: ARIA14

Technology: aria

Type: Technique

When to Use

+ + + + Using aria-label to provide an accessible name where a visible label cannot be used + + + + +

Using aria-label to provide an accessible name where a visible label cannot be used

+
+

ID: ARIA14

+

Technology: aria

+

Type: Technique

+
+
+

When to Use

Technologies that support Accessible Rich Internet Applications (WAI-ARIA).

-

Description

-

For sighted users, the context and visual appearance of an element can provide sufficient cues to determine the purpose. An example is the 'X' often used in the top right corner of pop-up divs (light boxes) to indicate the control for closing the div. -

-

In some situations, elements can be given the attribute aria-label to provide an accessible name for situations when there is no visible label due to a chosen design approach or layout but the context and visual appearance of the control make its purpose clear.

+
+
+

Description

+

For sighted users, the context and visual appearance of an element can provide sufficient cues to determine the purpose. An example is the “×” often used in the top-right corner of dialogs to indicate the control for closing the dialog. While it might be visually clear that the button with the “×” symbol closes the dialog, users with assistive technologies rely on accessible names that clearly communicate the purpose of components, in this case “Close”. +

+

When no clear visible text label is available due to design decisions, the accessible name can be set by using the aria-label attribute instead, provided that the element has an implicit or explicit role that supports naming.

+ +

The aria-label attribute can also be used to provide an accessible name for custom controls that are not labelable elements, and cannot therefore use a <label> element with the for attribute.

-

In other situations, elements can be given the attribute aria-label to provide an accessible name when the native HTML labeling element is not supported by the control - for example, when a div set to contentEditable is used instead of native form elements such as input type="text" or textarea in order to provide a richer text editing experience.

+

For instance, aria-label or aria-labelledby are the most suitable way to provide an accessible name when a <div> element is made editable using the contentEditable attribute, instead of native form elements such as <input type="text"> or <textarea> in order to provide a richer text editing experience.

-

Examples

+
+
+

Examples

-

A close button in a pop-up box

- -

On a page, a link displays a pop-up box (a div) with additional information. The 'close' element is implemented as a button containing merely the letter 'X'. The property aria-label="close" is used to provide an accessible name to the button.

-
<div id="box">
-   This is a pop-up box.
-   <button aria-label="Close">X</button>				
-</div>
-

Working example: Close button example. -

- +

A close button in a dialog

+ +

On a page, a button displays a dialog (a <div> element) with additional information. The “close” element is implemented as a <button> containing merely the symbol “×”. The property aria-label="close" is used to provide an accessible name to the button.

+
<dialog id="dialog">
+  This is the content of the dialog.
+  <button aria-label="Close">×</button>
+</dialog>
+

Working example: Close button example. +

+
-
-

A phone number with multiple fields

- -
<div role="group" aria-labelledby="groupLabel">
+      
+

A phone number with multiple fields

+ +
<div role="group" aria-labelledby="groupLabel">
   <span id="groupLabel">Work Phone</span>
   +<input autocomplete="tel-country-code" type="number" aria-label="country code">
   <input autocomplete="tel-area-code" type="number" aria-label="area code">
   <input autocomplete="tel-local" type="number" aria-label="subscriber number">
 </div>
- +
-

Tests

-

Procedure

-

For elements that use aria-label: -

-
    -
  1. Check that the value of the aria-label attribute properly describes the purpose of an element where user input is required -
  2. -
+
+
+

Tests

+
+

Procedure

+

For elements that use the aria-label attribute: +

+
    +
  1. Check that the value of the aria-label attribute properly describes the purpose of an element where user input is required +
  2. +
-

Expected Results

-
    -
  • #1 is true.
  • -
+
+

Expected Results

+
    +
  • #1 is true.
  • +
-

Resources

- - - -
- \ No newline at end of file +
+ +
+

Resources

+ + + +
+ + + \ No newline at end of file diff --git a/working-examples/aria-label-accessible-name-dialog/index.html b/working-examples/aria-label-accessible-name-dialog/index.html new file mode 100644 index 0000000000..a65effcec1 --- /dev/null +++ b/working-examples/aria-label-accessible-name-dialog/index.html @@ -0,0 +1,51 @@ + + + + + + aria-label Example: close button + + + + + + + +

+ + + This is the content of the dialog. + + + + + + \ No newline at end of file diff --git a/working-examples/aria-label-invisible-label-box/index.html b/working-examples/aria-label-invisible-label-box/index.html deleted file mode 100644 index 0eec3741ee..0000000000 --- a/working-examples/aria-label-invisible-label-box/index.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - aria-label: 2. Example close-button - - - - - - - -

Display a div box

- -
- This is a div box. - -
- - - \ No newline at end of file