From de49b6102d87213d84ae17be65c5b54cd76af3cc Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Thu, 28 Feb 2019 14:42:26 +0100
Subject: [PATCH 01/55] Guideline for labeling and describing
Fixes #70, fixes #74.
---
draft-labelling-describing.md | 105 ++++++++++++++++++++++++++++++++++
1 file changed, 105 insertions(+)
create mode 100644 draft-labelling-describing.md
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
new file mode 100644
index 0000000000..b2dd89a489
--- /dev/null
+++ b/draft-labelling-describing.md
@@ -0,0 +1,105 @@
+Labeling and Describing
+
+## Labels
+
+A label is used as the accessible name for an element.
+
+For elements with certain roles, the label is taken from the element’s contents by default. This can be overridden with a label from the author by using the aria-labelledby or aria-label attributes. If the label from the element’s contents is appropriate, then it should not be overridden with those attributes.
+
+In the following example, a link (with default role "link") gets its label from the element’s contents.
+
+```
+Home
+```
+
+
+The following roles get the label from the contents by default:
+
+* button
+
+* cell
+
+* checkbox
+
+* columnheader
+
+* gridcell
+
+* heading
+
+* link
+
+* menuitem
+
+* menuitemcheckbox
+
+* menuitemradio
+
+* option
+
+* radio
+
+* row
+
+* rowgroup
+
+* rowheader
+
+* sectionhead
+
+* switch
+
+* tab
+
+* tooltip
+
+* treeitem
+
+If the element’s contents is not appropriate as a label, but there is an element that can be used as the label, then authors should use the aria-labelledby attribute.
+
+In the following example, an element with the "switch" role is labelled by a previous sibling element.
+
+```
+Night mode
+
+```
+
+
+In some cases the combination of the element’s contents and another element would be appropriate as a label. In such situations, the aria-labelledby should be used and reference both the element itself and the other element.
+
+In the following example, a "read more" link is labelled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
+
+```
+7 ways you can help save the bees
+Bees are disappearing rapidly.
+Here are seven things you can do to help.
+Read more...
+```
+
+
+If there is no visible label that is appropriate, authors should use the aria-label attribute to set the label for the element.
+
+In the following example, a close button contains an "X" and is given the label “Close” using the aria-label attribute.
+
+```
+X
+```
+
+
+### Accessible name calculation
+
+aria-label vs aria-labelledby
+
+aria-placeholder, placeholder, title
+
+## Descriptions
+
+aria-describedby
+
+aria-details
+
+aria-roledescription
+
+### Accessible description calculation
+
+aria-describedby, aria-details, aria-placeholder?, placeholder, title
From 713aa1feae522bac2b340efce0a39361d55b7a3d Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Mon, 4 Mar 2019 16:29:51 +0100
Subject: [PATCH 02/55] Write about roles that don't get name from content
Also remove sectionhead as it is an abstract role, and include an early draft of accessible name calculation.
---
draft-labelling-describing.md | 48 ++++++++++++++++++++++++++++++++---
1 file changed, 44 insertions(+), 4 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index b2dd89a489..3955a3a0a4 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -45,8 +45,6 @@ The following roles get the label from the contents by default:
* rowheader
-* sectionhead
-
* switch
* tab
@@ -86,11 +84,53 @@ In the following example, a close button contains an "X" and is given the label
```
+Other roles do not get the label from the contents of the element. In these cases, an author-provided label does not override the element’s contents, but augments it. Examples of such roles are (note that this is not a complete list):
+
+* alertdialog
+
+* application
+
+* article
+
+* banner
+
+* complementary
+
+* navigation
+
+* radiogroup
+
+* search
+
+* status
+
+For example, the navigation landmark could be labeled with the purpose of the landmark. In the following snippet, a breadcrumbs navigation is labeled using the aria-label attribute.
+
+```
+
+```
+
+
### Accessible name calculation
-aria-label vs aria-labelledby
+User agents follow the accessible name calculation algorithm to get the label for an element.
+
+The following attributes are considered when calculating the accessible name, in this order:
+
+1. aria-labelledby
+
+2. aria-label (with some exceptions)
+
+3. Host-language specific attributes or elements (e.g. the title attribute in HTML)
+
+4. In some cases, for widgets that have a value, that value.
-aria-placeholder, placeholder, title
+5. If the element’s role allows name from content, the element’s contents.
## Descriptions
From ae9a5edf510c7aff73e7e11df669986e2079a83d Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Thu, 7 Mar 2019 14:59:55 +0100
Subject: [PATCH 03/55] Say accessible name instead of label; flesh out
accessible name calculation
---
draft-labelling-describing.md | 104 +++++++++++++++++++++++++++-------
1 file changed, 83 insertions(+), 21 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index 3955a3a0a4..9ba8530c6a 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -1,19 +1,25 @@
Labeling and Describing
-## Labels
+## Introduction
-A label is used as the accessible name for an element.
+An accessible name is a name or a label used to identify the element for users of assistive technology. For example, a button’s accessible name can be "OK".
-For elements with certain roles, the label is taken from the element’s contents by default. This can be overridden with a label from the author by using the aria-labelledby or aria-label attributes. If the label from the element’s contents is appropriate, then it should not be overridden with those attributes.
+An accessible description complements the accessible name with a description. An accessible description is always optional, and if present it does not need to be as brief as an accessible name.
-In the following example, a link (with default role "link") gets its label from the element’s contents.
+## Accessible name
+
+### Name from content by default
+
+For elements with certain roles, the accessible name is taken from the element’s contents by default. In the following example, a link (with default role "link") gets its accessible name from the element’s contents (“Home”).
```
Home
```
-The following roles get the label from the contents by default:
+The accessible name can be set explicitly by using the aria-labelledby or aria-label attributes. If the accessible name from the element’s contents is already good, then don’t use the aria-labelledby or aria-label attributes.
+
+The following roles get the accessible name from the contents by default:
* button
@@ -53,9 +59,9 @@ The following roles get the label from the contents by default:
* treeitem
-If the element’s contents is not appropriate as a label, but there is an element that can be used as the label, then authors should use the aria-labelledby attribute.
+If the element’s contents is not appropriate as a label, but there is an element that can be used as the label, then use the aria-labelledby attribute.
-In the following example, an element with the "switch" role is labelled by a previous sibling element.
+In the following example, an element with the "switch" role is labeled by a previous sibling element.
```
Night mode
@@ -63,28 +69,40 @@ In the following example, an element with the "switch" role is labelled by a pre
```
-In some cases the combination of the element’s contents and another element would be appropriate as a label. In such situations, the aria-labelledby should be used and reference both the element itself and the other element.
+Because a span element is used for the switch control, the HTML label element cannot be used to label it, since it only works with HTML elements that are form controls. However, the switch role can be used on an input element with type="checkbox”, and then HTML label can be used.
+
+```
+Night mode
+
+```
+
+
+In some cases, the combination of the element’s contents and another element would be appropriate as an accessible name. In such situations, use the aria-labelledby and reference both the element itself and the other element.
-In the following example, a "read more" link is labelled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
+In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
```
7 ways you can help save the bees
Bees are disappearing rapidly.
Here are seven things you can do to help.
-Read more...
+Read more...
```
-If there is no visible label that is appropriate, authors should use the aria-label attribute to set the label for the element.
+If there is no content that is appropriate to use as the accessible name, use the aria-label attribute to set the label for the element directly.
-In the following example, a close button contains an "X" and is given the label “Close” using the aria-label attribute.
+In the following example, a close button contains an "X" and is given the accessible name “Close” using the aria-label attribute.
```
X
```
-Other roles do not get the label from the contents of the element. In these cases, an author-provided label does not override the element’s contents, but augments it. Examples of such roles are (note that this is not a complete list):
+### Name from author only
+
+Some roles do not get the accessible name from the contents of the element. An accessible name set with the aria-labelledby or aria-label attributes does not override the contents of such elements.
+
+Examples of such roles are (note that this is not a complete list):
* alertdialog
@@ -104,7 +122,7 @@ Other roles do not get the label from the contents of the element. In these case
* status
-For example, the navigation landmark could be labeled with the purpose of the landmark. In the following snippet, a breadcrumbs navigation is labeled using the aria-label attribute.
+For example, the navigation landmark could be labeled with the purpose of the landmark. In the following snippet, a breadcrumbs navigation region is labeled using the aria-label attribute.
```
@@ -116,21 +134,65 @@ For example, the navigation landmark could be labeled with the purpose of the la
```
+Alternatively, this can use the HTML nav element, which has the "navigation" role by default:
+
+```
+
+ You are here:
+ Home >
+ Books >
+ Children's books
+
+```
+
+
### Accessible name calculation
-User agents follow the accessible name calculation algorithm to get the label for an element.
+User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
-The following attributes are considered when calculating the accessible name, in this order:
+The aria-labelledby attribute is used first, then the aria-label attribute, then host-language-specific attributes or elements (e.g., the alt attribute on HTML img) or, for roles that can take the name from content, the element’s contents.
-1. aria-labelledby
+For example, an img element with just a src attribute has no accessible name (don’t do this):
-2. aria-label (with some exceptions)
+```
+
+```
+
+
+If there is a title attribute, then that is used as the accessible name:
+
+```
+
+```
+
+
+If there is also an alt attribute, then that is used as the accessible name, and the title attribute is instead used as the accessible description:
-3. Host-language specific attributes or elements (e.g. the title attribute in HTML)
+```
+
+```
-4. In some cases, for widgets that have a value, that value.
-5. If the element’s role allows name from content, the element’s contents.
+If there is also an aria-label attribute, then that overrides the alt attribute:
+
+```
+
+```
+
+
+If there is also an aria-labelledby attribute, that wins over the other attributes (don’t do this):
+
+```
+
+
The Queen, holding a pigeon.
+```
+
## Descriptions
From ce15b81ccd3f67f69cdac2947a7a42cd21eea103 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Tue, 12 Mar 2019 17:06:39 -0400
Subject: [PATCH 04/55] Rewrite and expand on labels
- Use "explicit label" and "implicit label" instead of "name from author" and "name from content".
- Expand on accessible name calculation.
---
draft-labelling-describing.md | 171 ++++++++++++++++++++--------------
1 file changed, 99 insertions(+), 72 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index 9ba8530c6a..375bc68b0c 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -2,64 +2,70 @@ Labeling and Describing
## Introduction
-An accessible name is a name or a label used to identify the element for users of assistive technology. For example, a button’s accessible name can be "OK".
+A label, also known as accessible name, is a name or a label used to identify the element for users of assistive technology. For example, a button’s label can be "OK".
-An accessible description complements the accessible name with a description. An accessible description is always optional, and if present it does not need to be as brief as an accessible name.
+An accessible description complements the label with a description. An accessible description is always optional, and if present it does not need to be as brief as a label.
-## Accessible name
+## Labels
-### Name from content by default
+There are two different ways to get the label for an element, depending on the element’s role.
-For elements with certain roles, the accessible name is taken from the element’s contents by default. In the following example, a link (with default role "link") gets its accessible name from the element’s contents (“Home”).
+* Implicit label by default
+
+* Explicit label only
+
+### Implicit label by default
+
+For elements with certain roles, the label is taken from the element’s contents by default. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
```
Home
```
-The accessible name can be set explicitly by using the aria-labelledby or aria-label attributes. If the accessible name from the element’s contents is already good, then don’t use the aria-labelledby or aria-label attributes.
+The label also can be set explicitly by using the `aria-labelledby` or `aria-label` attributes. If the implicit label (from the element’s contents) is already good, then don’t use the `aria-labelledby` or `aria-label` attributes.
-The following roles get the accessible name from the contents by default:
+The following roles get the label from the contents by default:
-* button
+* `button`
-* cell
+* `cell`
-* checkbox
+* `checkbox`
-* columnheader
+* `columnheader`
-* gridcell
+* `gridcell`
-* heading
+* `heading`
-* link
+* `link`
-* menuitem
+* `menuitem`
-* menuitemcheckbox
+* `menuitemcheckbox`
-* menuitemradio
+* `menuitemradio`
-* option
+* `option`
-* radio
+* `radio`
-* row
+* `row`
-* rowgroup
+* `rowgroup`
-* rowheader
+* `rowheader`
-* switch
+* `switch`
-* tab
+* `tab`
-* tooltip
+* `tooltip`
-* treeitem
+* `treeitem`
-If the element’s contents is not appropriate as a label, but there is an element that can be used as the label, then use the aria-labelledby attribute.
+If the element’s contents are not appropriate as a label, but there is an element that can be used as the label, then use the `aria-labelledby` attribute.
In the following example, an element with the "switch" role is labeled by a previous sibling element.
@@ -69,7 +75,7 @@ In the following example, an element with the "switch" role is labeled by a prev
```
-Because a span element is used for the switch control, the HTML label element cannot be used to label it, since it only works with HTML elements that are form controls. However, the switch role can be used on an input element with type="checkbox”, and then HTML label can be used.
+Because a `span` element is used for the switch control, the HTML `label` element cannot be used to label it, since it only works with HTML elements that are form controls. However, the `switch` role can be used on an `input` element with `type="checkbox”`, and then HTML `label` can be used.
```
Night mode
@@ -77,7 +83,7 @@ Because a span element is used for the switch control, the HTML label element ca
```
-In some cases, the combination of the element’s contents and another element would be appropriate as an accessible name. In such situations, use the aria-labelledby and reference both the element itself and the other element.
+In some cases, the combination of the element’s contents and another element would be appropriate as a label. In such situations, use the `aria-labelledby` and reference both the element itself and the other element.
In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
@@ -89,56 +95,44 @@ Here are seven things you can do to help.
```
-If there is no content that is appropriate to use as the accessible name, use the aria-label attribute to set the label for the element directly.
+If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
-In the following example, a close button contains an "X" and is given the accessible name “Close” using the aria-label attribute.
+In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
```
X
```
-### Name from author only
+### Explicit label only
-Some roles do not get the accessible name from the contents of the element. An accessible name set with the aria-labelledby or aria-label attributes does not override the contents of such elements.
+Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. An explicit label does not override the contents of such elements.
Examples of such roles are (note that this is not a complete list):
-* alertdialog
+* `alertdialog`
-* application
+* `application`
-* article
+* `article`
-* banner
+* `banner`
-* complementary
+* `complementary`
-* navigation
+* `navigation`
-* radiogroup
+* `radiogroup`
-* search
+* `search`
-* status
+* `status`
-For example, the navigation landmark could be labeled with the purpose of the landmark. In the following snippet, a breadcrumbs navigation region is labeled using the aria-label attribute.
+For example, the `navigation` landmark could be labeled with the purpose of the landmark. In the following snippet, a "breadcrumbs" navigation region is labeled explicitly using the `aria-labelledby` attribute. The HTML `nav` element has the `navigation` role by default.
```
-
-```
-
-
-Alternatively, this can use the HTML nav element, which has the "navigation" role by default:
-
-```
-
- You are here:
+
+ You are here:
Home >
Books >
Children's books
@@ -150,50 +144,83 @@ Alternatively, this can use the HTML nav element, which has the "navigation" rol
User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
-The aria-labelledby attribute is used first, then the aria-label attribute, then host-language-specific attributes or elements (e.g., the alt attribute on HTML img) or, for roles that can take the name from content, the element’s contents.
+User agents attempt to formulate labels for elements by walking through a list of potential naming methods and use the first that generates a name. The algorithm is roughly like this:
+
+1. First, the `aria-labelledby` attribute is used if present.
+
+2. If the label is still empty, the `aria-label` attribute is used if present.
+
+3. If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
+
+4. If the label is still empty, then for roles that can take implicit label by default, the element’s contents.
+
+5. Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
-For example, an img element with just a src attribute has no accessible name (don’t do this):
+Steps 1-2 are explicit label, and steps 3-5 are implicit label. The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
+
+For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
+
+#### Examples of non-recursive accessible name calculation
+
+For example, an img element with just a src attribute has no label (don’t do this):
```
```
-If there is a title attribute, then that is used as the accessible name:
+If there is a `title` attribute, then that is used as the label (fallback mechanism; generally avoid doing this):
```
```
-If there is also an alt attribute, then that is used as the accessible name, and the title attribute is instead used as the accessible description:
+If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
```
-
+
```
-If there is also an aria-label attribute, then that overrides the alt attribute:
+If there is also an `aria-label` attribute, then that overrides the `alt` attribute:
```
-
+
```
-If there is also an aria-labelledby attribute, that wins over the other attributes (don’t do this):
+If there is also an `aria-labelledby` attribute, that wins over the other attributes (the `aria-label` attribute ought to be removed if it is not used):
```
-
+
The Queen, holding a pigeon.
```
+#### Examples of recursive accessible name calculation
+
+The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
+
+In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
+
+```
+Move to
+```
+
+
+When following an `aria-labelledby` reference, the algorithm avoids following the same reference twice in order to not end up in infinite loops.
+
+In this example, the label for the button is computed by first following the `aria-labelledby` reference to the parent element, and then computing the label for that element from the child nodes, first visiting the `button` element again but ignoring the `aria-labelledby` reference and instead using the `aria-label` attribute, and then visiting the next child (the text node). The resulting label is "Remove meeting: Daily status report".
+
+```
+
+ X
+ Daily status report
+
+```
+
## Descriptions
aria-describedby
From f0ddc151e9b8050a0bccb56bcc5c3e17895b94e4 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Tue, 12 Mar 2019 18:10:16 -0400
Subject: [PATCH 05/55] First draft for descriptions
---
draft-labelling-describing.md | 46 ++++++++++++++++++++++++++++++++---
1 file changed, 42 insertions(+), 4 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index 375bc68b0c..d7e58c3b62 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -223,12 +223,50 @@ In this example, the label for the button is computed by first following the `ar
## Descriptions
-aria-describedby
+An element can be given an accessible description using the `aria-describedby` attribute or the `aria-details` attribute.
-aria-details
+The `aria-describedby` attribute works similarly to the `aria-labelledby` attribute. For example, a button could be described by a later paragraph.
-aria-roledescription
+```
+Move to trash
+...
+Items in the trash
+will be permanently removed after 30 days.
+```
+
+
+This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
+
+```
+Move to
+...
+Items in
+will be permanently removed after 30 days.
+```
+
+
+In some cases, a plain text description is insufficient. The `aria-details` attribute can be used in such situations. In this example, a text field for a passenger’s name (when booking a flight) has a description that is a list of three items, and contains a link to an external document with further details.
+
+```
+
+
+ Passenger 1 (adult)
+ Full name
+
+
+ ...
+
+```
+
+
+If both `aria-details` and `aria-describedby` are specified on an element, only the `aria-details` attribute is used. This can be useful in order to provide a fallback for user agents that don’t support `aria-details`.
### Accessible description calculation
-aria-describedby, aria-details, aria-placeholder?, placeholder, title
+Like the accessible name calculation, the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
+
+TODO ...
From 3e08581f6579de1f7d38849f9a0eb1951b819050 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Wed, 13 Mar 2019 18:39:50 -0400
Subject: [PATCH 06/55] Flesh out remaining text
---
draft-labelling-describing.md | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index d7e58c3b62..29f069a3ff 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -221,6 +221,17 @@ In this example, the label for the button is computed by first following the `ar
```
+It is also possible to reference an element using `aria-labelledby` even if that element is hidden. In the following example, the `span` element could be styled with CSS `display: none` and the `nav` element would still have the label "You are here:".
+
+```
+
+ You are here:
+ Home >
+ Books >
+ Children's books
+
+```
+
## Descriptions
An element can be given an accessible description using the `aria-describedby` attribute or the `aria-details` attribute.
@@ -238,7 +249,9 @@ will be permanently removed after 30 days.
This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
```
-Move to
+
+ Move to
+
...
Items in
will be permanently removed after 30 days.
@@ -267,6 +280,19 @@ If both `aria-details` and `aria-describedby` are specified on an element, only
### Accessible description calculation
-Like the accessible name calculation, the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
+Like the accessible name calculation (see the earlier section), the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
+
+The accessible description calculation algorithm is the same algorithm as the accessible name calculation algorithm, but it branches off in some places depending on whether a name or a description is being calculated. In particular, when collecting an accessible description, the algorithm uses `aria-describedby` instead of `aria-labelledby`.
-TODO ...
+As with `aria-labelledby`, it is possible to reference an element using `aria-describedby` even if that element is hidden.
+
+For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. The description could also be referenced from the text field directly with `aria-describedby`. The accessible description for the `input` element is "Your username is the name that you use to log in to this service.".
+
+```
+Username
+
+?
+
+ Your username is the name that you use to log in to this service.
+
+```
From 801539f77b45765dbfc600dd8a1eaba1f6d214b9 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Thu, 25 Apr 2019 16:35:32 +0200
Subject: [PATCH 07/55] Try to address Matt's comments
---
draft-labelling-describing.md | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index 29f069a3ff..cc5475e9b2 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -8,22 +8,24 @@ An accessible description complements the label with a description. An accessibl
## Labels
-There are two different ways to get the label for an element, depending on the element’s role.
+There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
-* Implicit label by default
+* Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive tecnologies.
-* Explicit label only
+* Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
-### Implicit label by default
-For elements with certain roles, the label is taken from the element’s contents by default. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
+### Label that represents the element
+
+For elements with certain roles, the label is taken from the element’s contents by default, and the label will represent the element when communicated to assistive technologies. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
```
Home
```
+This could be rendered to assistive technology as "link, Home"; the role and the label, not not repeating the content ("link, Home, Home").
-The label also can be set explicitly by using the `aria-labelledby` or `aria-label` attributes. If the implicit label (from the element’s contents) is already good, then don’t use the `aria-labelledby` or `aria-label` attributes.
+The label also can be set explicitly by using the `aria-labelledby` or `aria-label` attributes. If the label from the element’s contents is already good, then don’t use the `aria-labelledby` or `aria-label` attributes.
The following roles get the label from the contents by default:
@@ -104,9 +106,9 @@ In the following example, a close button contains an "X" and is given the label
```
-### Explicit label only
+### Label that augments the element
-Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. An explicit label does not override the contents of such elements.
+Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. For elements with these roles, a label augments the element, but does not override the contents.
Examples of such roles are (note that this is not a complete list):
@@ -152,11 +154,11 @@ User agents attempt to formulate labels for elements by walking through a list o
3. If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
-4. If the label is still empty, then for roles that can take implicit label by default, the element’s contents.
+4. If the label is still empty, then for roles that can take label from the element's content, the element’s contents.
5. Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
-Steps 1-2 are explicit label, and steps 3-5 are implicit label. The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
+The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
@@ -264,7 +266,7 @@ In some cases, a plain text description is insufficient. The `aria-details` attr
Passenger 1 (adult)
From 61f20ae26c4bce4d13c95c5ef91a9ad7001834bc Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Thu, 28 Feb 2019 14:42:26 +0100
Subject: [PATCH 08/55] Guideline for labeling and describing
Fixes #70, fixes #74.
---
draft-labelling-describing.md | 105 ++++++++++++++++++++++++++++++++++
1 file changed, 105 insertions(+)
create mode 100644 draft-labelling-describing.md
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
new file mode 100644
index 0000000000..b2dd89a489
--- /dev/null
+++ b/draft-labelling-describing.md
@@ -0,0 +1,105 @@
+Labeling and Describing
+
+## Labels
+
+A label is used as the accessible name for an element.
+
+For elements with certain roles, the label is taken from the element’s contents by default. This can be overridden with a label from the author by using the aria-labelledby or aria-label attributes. If the label from the element’s contents is appropriate, then it should not be overridden with those attributes.
+
+In the following example, a link (with default role "link") gets its label from the element’s contents.
+
+```
+Home
+```
+
+
+The following roles get the label from the contents by default:
+
+* button
+
+* cell
+
+* checkbox
+
+* columnheader
+
+* gridcell
+
+* heading
+
+* link
+
+* menuitem
+
+* menuitemcheckbox
+
+* menuitemradio
+
+* option
+
+* radio
+
+* row
+
+* rowgroup
+
+* rowheader
+
+* sectionhead
+
+* switch
+
+* tab
+
+* tooltip
+
+* treeitem
+
+If the element’s contents is not appropriate as a label, but there is an element that can be used as the label, then authors should use the aria-labelledby attribute.
+
+In the following example, an element with the "switch" role is labelled by a previous sibling element.
+
+```
+Night mode
+
+```
+
+
+In some cases the combination of the element’s contents and another element would be appropriate as a label. In such situations, the aria-labelledby should be used and reference both the element itself and the other element.
+
+In the following example, a "read more" link is labelled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
+
+```
+7 ways you can help save the bees
+Bees are disappearing rapidly.
+Here are seven things you can do to help.
+Read more...
+```
+
+
+If there is no visible label that is appropriate, authors should use the aria-label attribute to set the label for the element.
+
+In the following example, a close button contains an "X" and is given the label “Close” using the aria-label attribute.
+
+```
+X
+```
+
+
+### Accessible name calculation
+
+aria-label vs aria-labelledby
+
+aria-placeholder, placeholder, title
+
+## Descriptions
+
+aria-describedby
+
+aria-details
+
+aria-roledescription
+
+### Accessible description calculation
+
+aria-describedby, aria-details, aria-placeholder?, placeholder, title
From 879287127d16e7343547b645fb7a78051e7a3763 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Mon, 4 Mar 2019 16:29:51 +0100
Subject: [PATCH 09/55] Write about roles that don't get name from content
Also remove sectionhead as it is an abstract role, and include an early draft of accessible name calculation.
---
draft-labelling-describing.md | 48 ++++++++++++++++++++++++++++++++---
1 file changed, 44 insertions(+), 4 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index b2dd89a489..3955a3a0a4 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -45,8 +45,6 @@ The following roles get the label from the contents by default:
* rowheader
-* sectionhead
-
* switch
* tab
@@ -86,11 +84,53 @@ In the following example, a close button contains an "X" and is given the label
```
+Other roles do not get the label from the contents of the element. In these cases, an author-provided label does not override the element’s contents, but augments it. Examples of such roles are (note that this is not a complete list):
+
+* alertdialog
+
+* application
+
+* article
+
+* banner
+
+* complementary
+
+* navigation
+
+* radiogroup
+
+* search
+
+* status
+
+For example, the navigation landmark could be labeled with the purpose of the landmark. In the following snippet, a breadcrumbs navigation is labeled using the aria-label attribute.
+
+```
+
+```
+
+
### Accessible name calculation
-aria-label vs aria-labelledby
+User agents follow the accessible name calculation algorithm to get the label for an element.
+
+The following attributes are considered when calculating the accessible name, in this order:
+
+1. aria-labelledby
+
+2. aria-label (with some exceptions)
+
+3. Host-language specific attributes or elements (e.g. the title attribute in HTML)
+
+4. In some cases, for widgets that have a value, that value.
-aria-placeholder, placeholder, title
+5. If the element’s role allows name from content, the element’s contents.
## Descriptions
From c3ec1e9ced6189a2b6b7a85a9e09e376c45a48eb Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Thu, 7 Mar 2019 14:59:55 +0100
Subject: [PATCH 10/55] Say accessible name instead of label; flesh out
accessible name calculation
---
draft-labelling-describing.md | 104 +++++++++++++++++++++++++++-------
1 file changed, 83 insertions(+), 21 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index 3955a3a0a4..9ba8530c6a 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -1,19 +1,25 @@
Labeling and Describing
-## Labels
+## Introduction
-A label is used as the accessible name for an element.
+An accessible name is a name or a label used to identify the element for users of assistive technology. For example, a button’s accessible name can be "OK".
-For elements with certain roles, the label is taken from the element’s contents by default. This can be overridden with a label from the author by using the aria-labelledby or aria-label attributes. If the label from the element’s contents is appropriate, then it should not be overridden with those attributes.
+An accessible description complements the accessible name with a description. An accessible description is always optional, and if present it does not need to be as brief as an accessible name.
-In the following example, a link (with default role "link") gets its label from the element’s contents.
+## Accessible name
+
+### Name from content by default
+
+For elements with certain roles, the accessible name is taken from the element’s contents by default. In the following example, a link (with default role "link") gets its accessible name from the element’s contents (“Home”).
```
Home
```
-The following roles get the label from the contents by default:
+The accessible name can be set explicitly by using the aria-labelledby or aria-label attributes. If the accessible name from the element’s contents is already good, then don’t use the aria-labelledby or aria-label attributes.
+
+The following roles get the accessible name from the contents by default:
* button
@@ -53,9 +59,9 @@ The following roles get the label from the contents by default:
* treeitem
-If the element’s contents is not appropriate as a label, but there is an element that can be used as the label, then authors should use the aria-labelledby attribute.
+If the element’s contents is not appropriate as a label, but there is an element that can be used as the label, then use the aria-labelledby attribute.
-In the following example, an element with the "switch" role is labelled by a previous sibling element.
+In the following example, an element with the "switch" role is labeled by a previous sibling element.
```
Night mode
@@ -63,28 +69,40 @@ In the following example, an element with the "switch" role is labelled by a pre
```
-In some cases the combination of the element’s contents and another element would be appropriate as a label. In such situations, the aria-labelledby should be used and reference both the element itself and the other element.
+Because a span element is used for the switch control, the HTML label element cannot be used to label it, since it only works with HTML elements that are form controls. However, the switch role can be used on an input element with type="checkbox”, and then HTML label can be used.
+
+```
+Night mode
+
+```
+
+
+In some cases, the combination of the element’s contents and another element would be appropriate as an accessible name. In such situations, use the aria-labelledby and reference both the element itself and the other element.
-In the following example, a "read more" link is labelled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
+In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
```
7 ways you can help save the bees
Bees are disappearing rapidly.
Here are seven things you can do to help.
-Read more...
+Read more...
```
-If there is no visible label that is appropriate, authors should use the aria-label attribute to set the label for the element.
+If there is no content that is appropriate to use as the accessible name, use the aria-label attribute to set the label for the element directly.
-In the following example, a close button contains an "X" and is given the label “Close” using the aria-label attribute.
+In the following example, a close button contains an "X" and is given the accessible name “Close” using the aria-label attribute.
```
X
```
-Other roles do not get the label from the contents of the element. In these cases, an author-provided label does not override the element’s contents, but augments it. Examples of such roles are (note that this is not a complete list):
+### Name from author only
+
+Some roles do not get the accessible name from the contents of the element. An accessible name set with the aria-labelledby or aria-label attributes does not override the contents of such elements.
+
+Examples of such roles are (note that this is not a complete list):
* alertdialog
@@ -104,7 +122,7 @@ Other roles do not get the label from the contents of the element. In these case
* status
-For example, the navigation landmark could be labeled with the purpose of the landmark. In the following snippet, a breadcrumbs navigation is labeled using the aria-label attribute.
+For example, the navigation landmark could be labeled with the purpose of the landmark. In the following snippet, a breadcrumbs navigation region is labeled using the aria-label attribute.
```
@@ -116,21 +134,65 @@ For example, the navigation landmark could be labeled with the purpose of the la
```
+Alternatively, this can use the HTML nav element, which has the "navigation" role by default:
+
+```
+
+ You are here:
+ Home >
+ Books >
+ Children's books
+
+```
+
+
### Accessible name calculation
-User agents follow the accessible name calculation algorithm to get the label for an element.
+User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
-The following attributes are considered when calculating the accessible name, in this order:
+The aria-labelledby attribute is used first, then the aria-label attribute, then host-language-specific attributes or elements (e.g., the alt attribute on HTML img) or, for roles that can take the name from content, the element’s contents.
-1. aria-labelledby
+For example, an img element with just a src attribute has no accessible name (don’t do this):
-2. aria-label (with some exceptions)
+```
+
+```
+
+
+If there is a title attribute, then that is used as the accessible name:
+
+```
+
+```
+
+
+If there is also an alt attribute, then that is used as the accessible name, and the title attribute is instead used as the accessible description:
-3. Host-language specific attributes or elements (e.g. the title attribute in HTML)
+```
+
+```
-4. In some cases, for widgets that have a value, that value.
-5. If the element’s role allows name from content, the element’s contents.
+If there is also an aria-label attribute, then that overrides the alt attribute:
+
+```
+
+```
+
+
+If there is also an aria-labelledby attribute, that wins over the other attributes (don’t do this):
+
+```
+
+
The Queen, holding a pigeon.
+```
+
## Descriptions
From 6b4549288c1fdc71878da4afb29ece5b74e7de3e Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Tue, 12 Mar 2019 17:06:39 -0400
Subject: [PATCH 11/55] Rewrite and expand on labels
- Use "explicit label" and "implicit label" instead of "name from author" and "name from content".
- Expand on accessible name calculation.
---
draft-labelling-describing.md | 171 ++++++++++++++++++++--------------
1 file changed, 99 insertions(+), 72 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index 9ba8530c6a..375bc68b0c 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -2,64 +2,70 @@ Labeling and Describing
## Introduction
-An accessible name is a name or a label used to identify the element for users of assistive technology. For example, a button’s accessible name can be "OK".
+A label, also known as accessible name, is a name or a label used to identify the element for users of assistive technology. For example, a button’s label can be "OK".
-An accessible description complements the accessible name with a description. An accessible description is always optional, and if present it does not need to be as brief as an accessible name.
+An accessible description complements the label with a description. An accessible description is always optional, and if present it does not need to be as brief as a label.
-## Accessible name
+## Labels
-### Name from content by default
+There are two different ways to get the label for an element, depending on the element’s role.
-For elements with certain roles, the accessible name is taken from the element’s contents by default. In the following example, a link (with default role "link") gets its accessible name from the element’s contents (“Home”).
+* Implicit label by default
+
+* Explicit label only
+
+### Implicit label by default
+
+For elements with certain roles, the label is taken from the element’s contents by default. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
```
Home
```
-The accessible name can be set explicitly by using the aria-labelledby or aria-label attributes. If the accessible name from the element’s contents is already good, then don’t use the aria-labelledby or aria-label attributes.
+The label also can be set explicitly by using the `aria-labelledby` or `aria-label` attributes. If the implicit label (from the element’s contents) is already good, then don’t use the `aria-labelledby` or `aria-label` attributes.
-The following roles get the accessible name from the contents by default:
+The following roles get the label from the contents by default:
-* button
+* `button`
-* cell
+* `cell`
-* checkbox
+* `checkbox`
-* columnheader
+* `columnheader`
-* gridcell
+* `gridcell`
-* heading
+* `heading`
-* link
+* `link`
-* menuitem
+* `menuitem`
-* menuitemcheckbox
+* `menuitemcheckbox`
-* menuitemradio
+* `menuitemradio`
-* option
+* `option`
-* radio
+* `radio`
-* row
+* `row`
-* rowgroup
+* `rowgroup`
-* rowheader
+* `rowheader`
-* switch
+* `switch`
-* tab
+* `tab`
-* tooltip
+* `tooltip`
-* treeitem
+* `treeitem`
-If the element’s contents is not appropriate as a label, but there is an element that can be used as the label, then use the aria-labelledby attribute.
+If the element’s contents are not appropriate as a label, but there is an element that can be used as the label, then use the `aria-labelledby` attribute.
In the following example, an element with the "switch" role is labeled by a previous sibling element.
@@ -69,7 +75,7 @@ In the following example, an element with the "switch" role is labeled by a prev
```
-Because a span element is used for the switch control, the HTML label element cannot be used to label it, since it only works with HTML elements that are form controls. However, the switch role can be used on an input element with type="checkbox”, and then HTML label can be used.
+Because a `span` element is used for the switch control, the HTML `label` element cannot be used to label it, since it only works with HTML elements that are form controls. However, the `switch` role can be used on an `input` element with `type="checkbox”`, and then HTML `label` can be used.
```
Night mode
@@ -77,7 +83,7 @@ Because a span element is used for the switch control, the HTML label element ca
```
-In some cases, the combination of the element’s contents and another element would be appropriate as an accessible name. In such situations, use the aria-labelledby and reference both the element itself and the other element.
+In some cases, the combination of the element’s contents and another element would be appropriate as a label. In such situations, use the `aria-labelledby` and reference both the element itself and the other element.
In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
@@ -89,56 +95,44 @@ Here are seven things you can do to help.
```
-If there is no content that is appropriate to use as the accessible name, use the aria-label attribute to set the label for the element directly.
+If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
-In the following example, a close button contains an "X" and is given the accessible name “Close” using the aria-label attribute.
+In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
```
X
```
-### Name from author only
+### Explicit label only
-Some roles do not get the accessible name from the contents of the element. An accessible name set with the aria-labelledby or aria-label attributes does not override the contents of such elements.
+Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. An explicit label does not override the contents of such elements.
Examples of such roles are (note that this is not a complete list):
-* alertdialog
+* `alertdialog`
-* application
+* `application`
-* article
+* `article`
-* banner
+* `banner`
-* complementary
+* `complementary`
-* navigation
+* `navigation`
-* radiogroup
+* `radiogroup`
-* search
+* `search`
-* status
+* `status`
-For example, the navigation landmark could be labeled with the purpose of the landmark. In the following snippet, a breadcrumbs navigation region is labeled using the aria-label attribute.
+For example, the `navigation` landmark could be labeled with the purpose of the landmark. In the following snippet, a "breadcrumbs" navigation region is labeled explicitly using the `aria-labelledby` attribute. The HTML `nav` element has the `navigation` role by default.
```
-
-```
-
-
-Alternatively, this can use the HTML nav element, which has the "navigation" role by default:
-
-```
-
- You are here:
+
+ You are here:
Home >
Books >
Children's books
@@ -150,50 +144,83 @@ Alternatively, this can use the HTML nav element, which has the "navigation" rol
User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
-The aria-labelledby attribute is used first, then the aria-label attribute, then host-language-specific attributes or elements (e.g., the alt attribute on HTML img) or, for roles that can take the name from content, the element’s contents.
+User agents attempt to formulate labels for elements by walking through a list of potential naming methods and use the first that generates a name. The algorithm is roughly like this:
+
+1. First, the `aria-labelledby` attribute is used if present.
+
+2. If the label is still empty, the `aria-label` attribute is used if present.
+
+3. If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
+
+4. If the label is still empty, then for roles that can take implicit label by default, the element’s contents.
+
+5. Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
-For example, an img element with just a src attribute has no accessible name (don’t do this):
+Steps 1-2 are explicit label, and steps 3-5 are implicit label. The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
+
+For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
+
+#### Examples of non-recursive accessible name calculation
+
+For example, an img element with just a src attribute has no label (don’t do this):
```
```
-If there is a title attribute, then that is used as the accessible name:
+If there is a `title` attribute, then that is used as the label (fallback mechanism; generally avoid doing this):
```
```
-If there is also an alt attribute, then that is used as the accessible name, and the title attribute is instead used as the accessible description:
+If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
```
-
+
```
-If there is also an aria-label attribute, then that overrides the alt attribute:
+If there is also an `aria-label` attribute, then that overrides the `alt` attribute:
```
-
+
```
-If there is also an aria-labelledby attribute, that wins over the other attributes (don’t do this):
+If there is also an `aria-labelledby` attribute, that wins over the other attributes (the `aria-label` attribute ought to be removed if it is not used):
```
-
+
The Queen, holding a pigeon.
```
+#### Examples of recursive accessible name calculation
+
+The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
+
+In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
+
+```
+Move to
+```
+
+
+When following an `aria-labelledby` reference, the algorithm avoids following the same reference twice in order to not end up in infinite loops.
+
+In this example, the label for the button is computed by first following the `aria-labelledby` reference to the parent element, and then computing the label for that element from the child nodes, first visiting the `button` element again but ignoring the `aria-labelledby` reference and instead using the `aria-label` attribute, and then visiting the next child (the text node). The resulting label is "Remove meeting: Daily status report".
+
+```
+
+ X
+ Daily status report
+
+```
+
## Descriptions
aria-describedby
From 5727205ee618481b818d90539e5799251dd19e89 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Tue, 12 Mar 2019 18:10:16 -0400
Subject: [PATCH 12/55] First draft for descriptions
---
draft-labelling-describing.md | 46 ++++++++++++++++++++++++++++++++---
1 file changed, 42 insertions(+), 4 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index 375bc68b0c..d7e58c3b62 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -223,12 +223,50 @@ In this example, the label for the button is computed by first following the `ar
## Descriptions
-aria-describedby
+An element can be given an accessible description using the `aria-describedby` attribute or the `aria-details` attribute.
-aria-details
+The `aria-describedby` attribute works similarly to the `aria-labelledby` attribute. For example, a button could be described by a later paragraph.
-aria-roledescription
+```
+Move to trash
+...
+Items in the trash
+will be permanently removed after 30 days.
+```
+
+
+This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
+
+```
+Move to
+...
+Items in
+will be permanently removed after 30 days.
+```
+
+
+In some cases, a plain text description is insufficient. The `aria-details` attribute can be used in such situations. In this example, a text field for a passenger’s name (when booking a flight) has a description that is a list of three items, and contains a link to an external document with further details.
+
+```
+
+
+ Passenger 1 (adult)
+ Full name
+
+
+ ...
+
+```
+
+
+If both `aria-details` and `aria-describedby` are specified on an element, only the `aria-details` attribute is used. This can be useful in order to provide a fallback for user agents that don’t support `aria-details`.
### Accessible description calculation
-aria-describedby, aria-details, aria-placeholder?, placeholder, title
+Like the accessible name calculation, the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
+
+TODO ...
From 07cd850ce6ccceff914c91d69933627959546965 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Wed, 13 Mar 2019 18:39:50 -0400
Subject: [PATCH 13/55] Flesh out remaining text
---
draft-labelling-describing.md | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index d7e58c3b62..29f069a3ff 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -221,6 +221,17 @@ In this example, the label for the button is computed by first following the `ar
```
+It is also possible to reference an element using `aria-labelledby` even if that element is hidden. In the following example, the `span` element could be styled with CSS `display: none` and the `nav` element would still have the label "You are here:".
+
+```
+
+ You are here:
+ Home >
+ Books >
+ Children's books
+
+```
+
## Descriptions
An element can be given an accessible description using the `aria-describedby` attribute or the `aria-details` attribute.
@@ -238,7 +249,9 @@ will be permanently removed after 30 days.
This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
```
-Move to
+
+ Move to
+
...
Items in
will be permanently removed after 30 days.
@@ -267,6 +280,19 @@ If both `aria-details` and `aria-describedby` are specified on an element, only
### Accessible description calculation
-Like the accessible name calculation, the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
+Like the accessible name calculation (see the earlier section), the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
+
+The accessible description calculation algorithm is the same algorithm as the accessible name calculation algorithm, but it branches off in some places depending on whether a name or a description is being calculated. In particular, when collecting an accessible description, the algorithm uses `aria-describedby` instead of `aria-labelledby`.
-TODO ...
+As with `aria-labelledby`, it is possible to reference an element using `aria-describedby` even if that element is hidden.
+
+For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. The description could also be referenced from the text field directly with `aria-describedby`. The accessible description for the `input` element is "Your username is the name that you use to log in to this service.".
+
+```
+Username
+
+?
+
+ Your username is the name that you use to log in to this service.
+
+```
From 78e912cafa714c75505a744a1c4dfc9f5fb71f53 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Thu, 25 Apr 2019 16:35:32 +0200
Subject: [PATCH 14/55] Try to address Matt's comments
---
draft-labelling-describing.md | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index 29f069a3ff..cc5475e9b2 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -8,22 +8,24 @@ An accessible description complements the label with a description. An accessibl
## Labels
-There are two different ways to get the label for an element, depending on the element’s role.
+There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
-* Implicit label by default
+* Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive tecnologies.
-* Explicit label only
+* Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
-### Implicit label by default
-For elements with certain roles, the label is taken from the element’s contents by default. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
+### Label that represents the element
+
+For elements with certain roles, the label is taken from the element’s contents by default, and the label will represent the element when communicated to assistive technologies. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
```
Home
```
+This could be rendered to assistive technology as "link, Home"; the role and the label, not not repeating the content ("link, Home, Home").
-The label also can be set explicitly by using the `aria-labelledby` or `aria-label` attributes. If the implicit label (from the element’s contents) is already good, then don’t use the `aria-labelledby` or `aria-label` attributes.
+The label also can be set explicitly by using the `aria-labelledby` or `aria-label` attributes. If the label from the element’s contents is already good, then don’t use the `aria-labelledby` or `aria-label` attributes.
The following roles get the label from the contents by default:
@@ -104,9 +106,9 @@ In the following example, a close button contains an "X" and is given the label
```
-### Explicit label only
+### Label that augments the element
-Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. An explicit label does not override the contents of such elements.
+Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. For elements with these roles, a label augments the element, but does not override the contents.
Examples of such roles are (note that this is not a complete list):
@@ -152,11 +154,11 @@ User agents attempt to formulate labels for elements by walking through a list o
3. If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
-4. If the label is still empty, then for roles that can take implicit label by default, the element’s contents.
+4. If the label is still empty, then for roles that can take label from the element's content, the element’s contents.
5. Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
-Steps 1-2 are explicit label, and steps 3-5 are implicit label. The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
+The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
@@ -264,7 +266,7 @@ In some cases, a plain text description is insufficient. The `aria-details` attr
Passenger 1 (adult)
From a8651d18866d16464b782df5eafd687e0b2b10f3 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Mon, 29 Apr 2019 19:52:02 +0200
Subject: [PATCH 15/55] Move draft into aria-practices.html
---
aria-practices.html | 268 +++++++++++++++++++++++++++++-
draft-labelling-describing.md | 300 ----------------------------------
2 files changed, 261 insertions(+), 307 deletions(-)
delete mode 100644 draft-labelling-describing.md
diff --git a/aria-practices.html b/aria-practices.html
index ea9a5acbee..222a1f53a7 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -477,7 +477,7 @@ WAI-ARIA Roles, States, and Properties
-
+
-
+
+
+ Labeling and describing
+
+
+ Introduction
+
+ A label, also known as accessible name, is a name or a label used to identify the element for users of assistive technology. For example, a button’s label can be "OK".
+
+ An accessible description complements the label with a description. An accessible description is always optional, and if present it does not need to be as brief as a label.
+
+
+
+ Labels
+
+ There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
+
+
+ Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive tecnologies.
+
+ Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
+
+
+
+ Label that represents the element
+
+ For elements with certain roles, the label is taken from the element’s contents by default, and the label will represent the element when communicated to assistive technologies. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
+
+ <a href="/">Home</a>
+
+ This could be rendered to assistive technology as "link, Home"; the role and the label, not not repeating the content ("link, Home, Home").
+
+ The label also can be set explicitly by using the `aria-labelledby` or `aria-label` attributes. If the label from the element’s contents is already good, then don’t use the `aria-labelledby` or `aria-label` attributes.
+
+ The following roles get the label from the contents by default:
+
+
+ `button`
+ `cell`
+ `checkbox`
+ `columnheader`
+ `gridcell`
+ `heading`
+ `link`
+ `menuitem`
+ `menuitemcheckbox`
+ `menuitemradio`
+ `option`
+ `radio`
+ `row`
+ `rowgroup`
+ `rowheader`
+ `switch`
+ `tab`
+ `tooltip`
+ `treeitem`
+
+
+ If the element’s contents are not appropriate as a label, but there is an element that can be used as the label, then use the `aria-labelledby` attribute.
+
+ In the following example, an element with the "switch" role is labeled by a previous sibling element.
+
+ <span id="night-mode-label">Night mode</span>
+<span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span>
+
+
+ Because a `span` element is used for the switch control, the HTML `label` element cannot be used to label it, since it only works with HTML elements that are form controls. However, the `switch` role can be used on an `input` element with `type="checkbox”`, and then HTML `label` can be used.
+
+ <label for="night-mode">Night mode</label>
+<input type="checkbox" role="switch" id="night-mode">
+
+
+ In some cases, the combination of the element’s contents and another element would be appropriate as a label. In such situations, use the `aria-labelledby` and reference both the element itself and the other element.
+
+ In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
+
+ <h2 id="bees-heading">7 ways you can help save the bees</h2>
+<p>Bees are disappearing rapidly.
+Here are seven things you can do to help.</p>
+<p><a id="bees-read-more" aria-labelledby="bees-read-more bees-heading">Read more...</a></p>
+
+ If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
+
+ In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
+
+ <button type="button" aria-label="Close">X</button>
+
+
+
+
+ Label that augments the element
+
+ Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. For elements with these roles, a label augments the element, but does not override the contents.
+
+ Examples of such roles are (note that this is not a complete list):
+
+
+ `alertdialog`
+ `application`
+ `article`
+ `banner`
+ `complementary`
+ `navigation`
+ `radiogroup`
+ `search`
+ `status`
+
+
+ For example, the `navigation` landmark could be labeled with the purpose of the landmark. In the following snippet, a "breadcrumbs"
+ navigation region is labeled explicitly using the `aria-labelledby` attribute. The HTML `nav` element has the `navigation` role by default.
+
+ <nav aria-labelledby="breadcrumbs-label">
+ <span id="breadcrumbs-label">You are here:</span>
+ <a href="/">Home</a> >
+ <a href="/books/">Books</a> >
+ <a>Children's books</a>
+</nav>
+
+
+
+ Accessible name calculation
+
+ User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
+
+ User agents attempt to formulate labels for elements by walking through a list of potential naming methods and use the first that generates a name. The algorithm is roughly like this:
+
+
+ First, the `aria-labelledby` attribute is used if present.
+ If the label is still empty, the `aria-label` attribute is used if present.
+ If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
+ If the label is still empty, then for roles that can take label from the element's content, the element’s contents.
+ Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
+
+
+ The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
+
+ For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
+
+
+ Examples of non-recursive accessible name calculation
+
+ For example, an img element with just a src attribute has no label (don’t do this):
+
+ <img src="photo.jpg">
+
+ If there is a `title` attribute, then that is used as the label (fallback mechanism; generally avoid doing this):
+
+ <img src="photo.jpg" title="The Queen, holding a pigeon.">
+
+ If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
+
+ <img src="photo.jpg" alt="The Queen, holding a pigeon." title="Photo: Rex Features">
+
+ If there is also an `aria-label` attribute, then that overrides the `alt` attribute:
+
+ <img src="photo.jpg" aria-label="The Queen, holding a pigeon." title="Photo: Rex Features"
+ alt="Sorry, this image failed to load.">
+
+ If there is also an `aria-labelledby` attribute, that wins over the other attributes (the `aria-label` attribute ought to be removed if it is not used):
+
+ <img src="photo.jpg" aria-label="This is ignored." title="Photo: Established Depiction"
+ alt="Sorry, this image failed to load." aria-labelledby="the-queen">
+<span id="the-queen">The Queen, holding a pigeon.</span>
+
+
+
+ Examples of recursive accessible name calculation
+
+ The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
+
+ In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
+
+ <button>Move to <img src="bin.svg" alt="trash"></button>
+
+ When following an `aria-labelledby` reference, the algorithm avoids following the same reference twice in order to not end up in infinite loops.
+
+ In this example, the label for the button is computed by first following the `aria-labelledby` reference to the parent element, and then computing the label for that element from the child nodes, first visiting the `button` element again but ignoring the `aria-labelledby` reference and instead using the `aria-label` attribute, and then visiting the next child (the text node). The resulting label is "Remove meeting: Daily status report".
+
+ <div id="meeting-1">
+ <button aria-labelledby="meeting-1"
+ aria-label="Remove meeting:">X</button>
+ Daily status report
+</div>
+
+ It is also possible to reference an element using `aria-labelledby` even if that element is hidden. In the following example, the `span` element could be styled with CSS `display: none` and the `nav` element would still have the label "You are here:".
+
+ <nav aria-labelledby="breadcrumbs-label">
+ <span id="breadcrumbs-label">You are here:</span>
+ <a href="/">Home</a> >
+ <a href="/books/">Books</a> >
+ <a>Children's books</a>
+</nav>
+
+
+
+
+
+ Descriptions
+
+ An element can be given an accessible description using the `aria-describedby` attribute or the `aria-details` attribute.
+
+ The `aria-describedby` attribute works similarly to the `aria-labelledby` attribute. For example, a button could be described by a later paragraph.
+
+ <button aria-describedby="trash-desc">Move to trash</button>
+...
+<p id="trash-desc">Items in the trash
+will be permanently removed after 30 days.</p>
+
+ This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
+
+ <button aria-describedby="trash-desc">
+ Move to <img src="bin.svg" alt="trash">
+</button>
+...
+<p id="trash-desc">Items in <img src="bin.svg" alt="the trash">
+will be permanently removed after 30 days.</p>
+
+ In some cases, a plain text description is insufficient. The `aria-details` attribute can be used in such situations. In this example, a text field for a passenger’s name (when booking a flight) has a description that is a list of three items, and contains a link to an external document with further details.
+
+ <ul id="full-name-desc">
+ <li>The passenger's name must match the name in their passport.</li>
+ <li>The name must consist of only characters in the A-Z range.</li>
+ <li><a href="faq.html#name">What if the name in the passport contains other characters?</a></li>
+</ul>
+<fieldset>
+ <legend>Passenger 1 (adult)</legend>
+ <p><label>Full name
+ <input name="full-name" aria-details="full-name-desc">
+ </label></p>
+ ...
+</fieldset>
+
+ If both `aria-details` and `aria-describedby` are specified on an element, only the `aria-details` attribute is used. This can be useful in order to provide a fallback for user agents that don’t support `aria-details`.
+
+
+ Accessible description calculation
+
+ Like the accessible name calculation (see the earlier section), the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
+
+ The accessible description calculation algorithm is the same algorithm as the accessible name calculation algorithm, but it branches off in some places depending on whether a name or a description is being calculated. In particular, when collecting an accessible description, the algorithm uses `aria-describedby` instead of `aria-labelledby`.
+
+ As with `aria-labelledby`, it is possible to reference an element using `aria-describedby` even if that element is hidden.
+
+ For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. The description could also be referenced from the text field directly with `aria-describedby`. The accessible description for the `input` element is "Your username is the name that you use to log in to this service.".
+
+ <label for="username">Username</label>
+<input id="username" name="username" aria-describedby="username-desc">
+<button aria-expanded="false" aria-controls="username-desc" aria-label="Help about username">?</button>
+<p id="username-desc" hidden>
+ Your username is the name that you use to log in to this service.
+</p>
+
+
+
+
Developing a Keyboard Interface
@@ -4988,7 +5242,7 @@
Indexes
Change History
Change history is maintained in a separate version-specific branch.
-
+
Acknowledgements
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
deleted file mode 100644
index cc5475e9b2..0000000000
--- a/draft-labelling-describing.md
+++ /dev/null
@@ -1,300 +0,0 @@
-Labeling and Describing
-
-## Introduction
-
-A label, also known as accessible name, is a name or a label used to identify the element for users of assistive technology. For example, a button’s label can be "OK".
-
-An accessible description complements the label with a description. An accessible description is always optional, and if present it does not need to be as brief as a label.
-
-## Labels
-
-There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
-
-* Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive tecnologies.
-
-* Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
-
-
-### Label that represents the element
-
-For elements with certain roles, the label is taken from the element’s contents by default, and the label will represent the element when communicated to assistive technologies. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
-
-```
-Home
-```
-
-This could be rendered to assistive technology as "link, Home"; the role and the label, not not repeating the content ("link, Home, Home").
-
-The label also can be set explicitly by using the `aria-labelledby` or `aria-label` attributes. If the label from the element’s contents is already good, then don’t use the `aria-labelledby` or `aria-label` attributes.
-
-The following roles get the label from the contents by default:
-
-* `button`
-
-* `cell`
-
-* `checkbox`
-
-* `columnheader`
-
-* `gridcell`
-
-* `heading`
-
-* `link`
-
-* `menuitem`
-
-* `menuitemcheckbox`
-
-* `menuitemradio`
-
-* `option`
-
-* `radio`
-
-* `row`
-
-* `rowgroup`
-
-* `rowheader`
-
-* `switch`
-
-* `tab`
-
-* `tooltip`
-
-* `treeitem`
-
-If the element’s contents are not appropriate as a label, but there is an element that can be used as the label, then use the `aria-labelledby` attribute.
-
-In the following example, an element with the "switch" role is labeled by a previous sibling element.
-
-```
-Night mode
-
-```
-
-
-Because a `span` element is used for the switch control, the HTML `label` element cannot be used to label it, since it only works with HTML elements that are form controls. However, the `switch` role can be used on an `input` element with `type="checkbox”`, and then HTML `label` can be used.
-
-```
-Night mode
-
-```
-
-
-In some cases, the combination of the element’s contents and another element would be appropriate as a label. In such situations, use the `aria-labelledby` and reference both the element itself and the other element.
-
-In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
-
-```
-7 ways you can help save the bees
-Bees are disappearing rapidly.
-Here are seven things you can do to help.
-Read more...
-```
-
-
-If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
-
-In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
-
-```
-X
-```
-
-
-### Label that augments the element
-
-Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. For elements with these roles, a label augments the element, but does not override the contents.
-
-Examples of such roles are (note that this is not a complete list):
-
-* `alertdialog`
-
-* `application`
-
-* `article`
-
-* `banner`
-
-* `complementary`
-
-* `navigation`
-
-* `radiogroup`
-
-* `search`
-
-* `status`
-
-For example, the `navigation` landmark could be labeled with the purpose of the landmark. In the following snippet, a "breadcrumbs" navigation region is labeled explicitly using the `aria-labelledby` attribute. The HTML `nav` element has the `navigation` role by default.
-
-```
-
- You are here:
- Home >
- Books >
- Children's books
-
-```
-
-
-### Accessible name calculation
-
-User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
-
-User agents attempt to formulate labels for elements by walking through a list of potential naming methods and use the first that generates a name. The algorithm is roughly like this:
-
-1. First, the `aria-labelledby` attribute is used if present.
-
-2. If the label is still empty, the `aria-label` attribute is used if present.
-
-3. If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
-
-4. If the label is still empty, then for roles that can take label from the element's content, the element’s contents.
-
-5. Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
-
-The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
-
-For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
-
-#### Examples of non-recursive accessible name calculation
-
-For example, an img element with just a src attribute has no label (don’t do this):
-
-```
-
-```
-
-
-If there is a `title` attribute, then that is used as the label (fallback mechanism; generally avoid doing this):
-
-```
-
-```
-
-
-If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
-
-```
-
-```
-
-
-If there is also an `aria-label` attribute, then that overrides the `alt` attribute:
-
-```
-
-```
-
-
-If there is also an `aria-labelledby` attribute, that wins over the other attributes (the `aria-label` attribute ought to be removed if it is not used):
-
-```
-
-The Queen, holding a pigeon.
-```
-
-
-#### Examples of recursive accessible name calculation
-
-The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
-
-In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
-
-```
-Move to
-```
-
-
-When following an `aria-labelledby` reference, the algorithm avoids following the same reference twice in order to not end up in infinite loops.
-
-In this example, the label for the button is computed by first following the `aria-labelledby` reference to the parent element, and then computing the label for that element from the child nodes, first visiting the `button` element again but ignoring the `aria-labelledby` reference and instead using the `aria-label` attribute, and then visiting the next child (the text node). The resulting label is "Remove meeting: Daily status report".
-
-```
-
- X
- Daily status report
-
-```
-
-It is also possible to reference an element using `aria-labelledby` even if that element is hidden. In the following example, the `span` element could be styled with CSS `display: none` and the `nav` element would still have the label "You are here:".
-
-```
-
- You are here:
- Home >
- Books >
- Children's books
-
-```
-
-## Descriptions
-
-An element can be given an accessible description using the `aria-describedby` attribute or the `aria-details` attribute.
-
-The `aria-describedby` attribute works similarly to the `aria-labelledby` attribute. For example, a button could be described by a later paragraph.
-
-```
-Move to trash
-...
-Items in the trash
-will be permanently removed after 30 days.
-```
-
-
-This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
-
-```
-
- Move to
-
-...
-Items in
-will be permanently removed after 30 days.
-```
-
-
-In some cases, a plain text description is insufficient. The `aria-details` attribute can be used in such situations. In this example, a text field for a passenger’s name (when booking a flight) has a description that is a list of three items, and contains a link to an external document with further details.
-
-```
-
-
- Passenger 1 (adult)
- Full name
-
-
- ...
-
-```
-
-
-If both `aria-details` and `aria-describedby` are specified on an element, only the `aria-details` attribute is used. This can be useful in order to provide a fallback for user agents that don’t support `aria-details`.
-
-### Accessible description calculation
-
-Like the accessible name calculation (see the earlier section), the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
-
-The accessible description calculation algorithm is the same algorithm as the accessible name calculation algorithm, but it branches off in some places depending on whether a name or a description is being calculated. In particular, when collecting an accessible description, the algorithm uses `aria-describedby` instead of `aria-labelledby`.
-
-As with `aria-labelledby`, it is possible to reference an element using `aria-describedby` even if that element is hidden.
-
-For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. The description could also be referenced from the text field directly with `aria-describedby`. The accessible description for the `input` element is "Your username is the name that you use to log in to this service.".
-
-```
-Username
-
-?
-
- Your username is the name that you use to log in to this service.
-
-```
From 7773aae5c534af0976f60e52a5aff9d70d34b16a Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Mon, 29 Apr 2019 20:00:47 +0200
Subject: [PATCH 16/55] Fix typo
---
aria-practices.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aria-practices.html b/aria-practices.html
index 222a1f53a7..c8e47318b6 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3714,7 +3714,7 @@ Labels
There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
- Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive tecnologies.
+ Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive technologies.
Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
From 1bf0f40b4b0368d7a4a83d569b6d86ab9cdbc745 Mon Sep 17 00:00:00 2001
From: Matt King
Date: Mon, 6 May 2019 10:59:41 -0700
Subject: [PATCH 17/55] Incomplete and rough draft of revised outline
---
aria-practices.html | 367 +++++++++++++++++++++-------------
draft-labelling-describing.md | 2 +-
2 files changed, 234 insertions(+), 135 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index c8e47318b6..9ebfae5dc6 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3697,41 +3697,121 @@ Examples
-
- Labeling and describing
-
-
- Introduction
-
- A label, also known as accessible name, is a name or a label used to identify the element for users of assistive technology. For example, a button’s label can be "OK".
+
+ Providing Accessible Names and Descriptions
+
+ Providing elements with accessible names, and where appropriate, accessible descriptions is one of the most fundamental and important responsibilities authors have when developing accessible web experiences.
+ While doing so is straight forward for most elements, technical mistakes that can have devistating impacts on users of assistive technologies are easy to make and unfortunately common.
+ To help authors provide effective and reliable accessible names and descriptions, this section explains their purpose, when authors need to provide them, how browsers assemble them, and rules for coding and composing them.
+ It then provides guidance for effectively employing the following naming and describing techniques and WAI-ARIA properties:
+
+
+ Naming with child content.
+ Naming by encapsulation with a label.
+ Naming with a String Attribute Via aria-label
.
+ Naming by Referencing Content with aria-labelledby
.
+ Naming with Legends and Captions.
+ Fallback Names Derived from Titles and Placeholders.
+ Describing by referencing content with aria-describedby
.
+ Describing by referencing content with aria-details
.
+ Fallback descriptions Derived from Titles and Placeholders.
+
- An accessible description complements the label with a description. An accessible description is always optional, and if present it does not need to be as brief as a label.
+
+ What ARE Accessible Names and Descriptions?
+
+ An accessible name is a short string, typically 1 to 3 words, that authors associate with an element to provide users of assistive technologies with a label for the element.
+ For example, an input field might have an accessible name of "User ID" or a button might be named "Submit".
+
+ An accessible name serves two primary purposes:
+
+ Convey the purpose or intent of the element.
+ Distinguish it from other elements on the page.
+
+
+ Both the WAI-ARIA specification and WCAG require all focusable, interactive elements to have an accessible name.
+ In addition dialogs and some structural containers, such as tables and regions , are required to have a name.
+ Many other elements can be named, but whether a name will enhance the accessible experience is determined by various characteristics of the surrounding context.
+ Finally, there are some elements where providing an accessible name is technically possible but not advisable.
+ The Accessible Name Guidance by Role section lists naming requirements and guidelines for every ARIA role.
+
+
+ An accessible description is also an author-provided string that is rendered by assistive technologies.
+ Authors supply a description when there is a need to associate additional information with an element, such as instructions or format requirements for an input field.
+ Because they are usually significantly longer than names, assistive technologies present descriptions differently from names and other element attributes.
+ For instance, a screen reader may announce a description of an element after its name, role, value (if it is an input), and any relevant states or properties.
+
-
-
- Labels
-
+
+
+ How Are Name and Description Strings Derived?
+
+ Because there are several elements and attributes for specifying text to include in an accessible name or description string, and because they can be combined in a practically endless number of ways, browsers have to implement a fairly complex algorithm for assembling the strings.
+The section on accessible name calculation provides a detailed explanation of the algorithm.
+However, most authors do not need a detailed understanding of the algorithm since nearly all elements can be named or described by implementing the coding patterns described in the naming techniques section and following the guidance provided by the cardinal rules for naming.
+
+
+
+
+ Cardinal Rules of Naming
+
+
+ Rule 1: Heed Warnings and Test Thoroughly
+
+ because the aria-label
and aria-labelledby
attributes override content contained in some elementss, they can block assistive technology access to some on-screen text.
+ Thus
+ , to both serve an optimal experience and avoid potentially disasterous mistakes, it is essential to understand when and how these two attributes override element text.
+
There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
-
Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive technologies.
-
Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
-
+
+
+
- Label that represents the element
-
+ Rule 2: Prefer Visible Text
+
+ When a user interface includes visible text that could be used to provide an appropriate accessible name, using the visible text for the accessible name simplifies maintenance, prevents bugs, and reduces language translation requirements, which leads to a more robust accessible experience.
+ The naming techniques described in the sections below emphasize techniques for utilizing on-screen text.
+
+
+
+
+ Rule 3: Prefer Native Techniques
+ That is, in HTML documents, prefer HTML naming techniques, such as the HTML label element.
+
+
+ Rule 4: Avoid Browser Fallback
+
+ Talk about how fallbacks can be less robust because of potential implementation inconsistency.
+ title and placeholder
+
+
+
+
+ Rule 5: Compose Brief, Useful Names
+
+ Mention some good properties of names, such as uniqueness, brevity, and clarity.
+ Refer user to section on best practices for composing effective accessible names.
+ Example practice: Do NOT include a WAI-ARIA role name in the accessible name. For example, do not include the word "button" in the name of a button or the word "navigation" in the name of a navigation region.
+
+
+
+
+
+ Naming Techniques
+
+
+ Naming with Child Content
For elements with certain roles, the label is taken from the element’s contents by default, and the label will represent the element when communicated to assistive technologies. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
<a href="/">Home</a>
This could be rendered to assistive technology as "link, Home"; the role and the label, not not repeating the content ("link, Home, Home").
-
- The label also can be set explicitly by using the `aria-labelledby` or `aria-label` attributes. If the label from the element’s contents is already good, then don’t use the `aria-labelledby` or `aria-label` attributes.
-
+
The following roles get the label from the contents by default:
-
`button`
`cell`
@@ -3753,7 +3833,18 @@ Label that represents the element
`tooltip`
`treeitem`
+
+
+
+ Naming with a String Attribute Via aria-label
+ If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
+ In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
+
+ <button type="button" aria-label="Close">X</button>
+
+
+ Naming with Referenced Content Via aria-labeledby
If the element’s contents are not appropriate as a label, but there is an element that can be used as the label, then use the `aria-labelledby` attribute.
In the following example, an element with the "switch" role is labeled by a previous sibling element.
@@ -3761,13 +3852,11 @@ Label that represents the element
<span id="night-mode-label">Night mode</span>
<span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span>
-
Because a `span` element is used for the switch control, the HTML `label` element cannot be used to label it, since it only works with HTML elements that are form controls. However, the `switch` role can be used on an `input` element with `type="checkbox”`, and then HTML `label` can be used.
<label for="night-mode">Night mode</label>
<input type="checkbox" role="switch" id="night-mode">
-
In some cases, the combination of the element’s contents and another element would be appropriate as a label. In such situations, use the `aria-labelledby` and reference both the element itself and the other element.
In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
@@ -3776,13 +3865,6 @@ Label that represents the element
<p>Bees are disappearing rapidly.
Here are seven things you can do to help.</p>
<p><a id="bees-read-more" aria-labelledby="bees-read-more bees-heading">Read more...</a></p>
-
- If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
-
- In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
-
- <button type="button" aria-label="Close">X</button>
-
@@ -3814,140 +3896,157 @@ Label that augments the element
<a>Children's books</a>
</nav>
+
+
+
+ Composing Effective and User-friendly Accessible Names
+ Todo: Write a section that describes how to make good names, i.e., brief, descriptive, unique, front-loaded, no role names, etc.
+
+
+
+ Accessible Name Guidance by Role
+ Todo: build a table with every concrete role with columns for:
+
+ role
+ Name Required?: with values of always, sometimes, or never
+ Named by Content?: values of Yes or No
+ Guidance: Explains sometimes and never for name required. Provides warning if named from content.
+
+
+
+
+ Accessible name calculation
+ User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
+ User agents attempt to formulate labels for elements by walking through a list of potential naming methods and use the first that generates a name. The algorithm is roughly like this:
+
+ First, the `aria-labelledby` attribute is used if present.
+ If the label is still empty, the `aria-label` attribute is used if present.
+ If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
+ If the label is still empty, then for roles that can take label from the element's content, the element’s contents.
+ Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
+
-
- Accessible name calculation
-
- User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
-
- User agents attempt to formulate labels for elements by walking through a list of potential naming methods and use the first that generates a name. The algorithm is roughly like this:
-
-
- First, the `aria-labelledby` attribute is used if present.
- If the label is still empty, the `aria-label` attribute is used if present.
- If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
- If the label is still empty, then for roles that can take label from the element's content, the element’s contents.
- Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
-
-
- The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
+ The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
- For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
+ For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
-
- Examples of non-recursive accessible name calculation
+
+ Examples of non-recursive accessible name calculation
- For example, an img element with just a src attribute has no label (don’t do this):
+ For example, an img element with just a src attribute has no label (don’t do this):
- <img src="photo.jpg">
+ <img src="photo.jpg">
- If there is a `title` attribute, then that is used as the label (fallback mechanism; generally avoid doing this):
+ If there is a `title` attribute, then that is used as the label (fallback mechanism; generally avoid doing this):
- <img src="photo.jpg" title="The Queen, holding a pigeon.">
+ <img src="photo.jpg" title="The Queen, holding a pigeon.">
- If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
+ If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
- <img src="photo.jpg" alt="The Queen, holding a pigeon." title="Photo: Rex Features">
+ <img src="photo.jpg" alt="The Queen, holding a pigeon." title="Photo: Rex Features">
- If there is also an `aria-label` attribute, then that overrides the `alt` attribute:
+ If there is also an `aria-label` attribute, then that overrides the `alt` attribute:
- <img src="photo.jpg" aria-label="The Queen, holding a pigeon." title="Photo: Rex Features"
- alt="Sorry, this image failed to load.">
+ <img src="photo.jpg" aria-label="The Queen, holding a pigeon." title="Photo: Rex Features"
+ alt="Sorry, this image failed to load.">
- If there is also an `aria-labelledby` attribute, that wins over the other attributes (the `aria-label` attribute ought to be removed if it is not used):
+ If there is also an `aria-labelledby` attribute, that wins over the other attributes (the `aria-label` attribute ought to be removed if it is not used):
- <img src="photo.jpg" aria-label="This is ignored." title="Photo: Established Depiction"
- alt="Sorry, this image failed to load." aria-labelledby="the-queen">
-<span id="the-queen">The Queen, holding a pigeon.</span>
-
+ <img src="photo.jpg" aria-label="This is ignored." title="Photo: Established Depiction"
+ alt="Sorry, this image failed to load." aria-labelledby="the-queen">
+ <span id="the-queen">The Queen, holding a pigeon.</span>
+
-
- Examples of recursive accessible name calculation
+
+ Examples of recursive accessible name calculation
- The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
+ The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
- In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
+ In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
- <button>Move to <img src="bin.svg" alt="trash"></button>
+ <button>Move to <img src="bin.svg" alt="trash"></button>
- When following an `aria-labelledby` reference, the algorithm avoids following the same reference twice in order to not end up in infinite loops.
+ When following an `aria-labelledby` reference, the algorithm avoids following the same reference twice in order to not end up in infinite loops.
- In this example, the label for the button is computed by first following the `aria-labelledby` reference to the parent element, and then computing the label for that element from the child nodes, first visiting the `button` element again but ignoring the `aria-labelledby` reference and instead using the `aria-label` attribute, and then visiting the next child (the text node). The resulting label is "Remove meeting: Daily status report".
+ In this example, the label for the button is computed by first following the `aria-labelledby` reference to the parent element, and then computing the label for that element from the child nodes, first visiting the `button` element again but ignoring the `aria-labelledby` reference and instead using the `aria-label` attribute, and then visiting the next child (the text node). The resulting label is "Remove meeting: Daily status report".
- <div id="meeting-1">
- <button aria-labelledby="meeting-1"
- aria-label="Remove meeting:">X</button>
- Daily status report
-</div>
+ <div id="meeting-1">
+ <button aria-labelledby="meeting-1"
+ aria-label="Remove meeting:">X</button>
+ Daily status report
+ </div>
- It is also possible to reference an element using `aria-labelledby` even if that element is hidden. In the following example, the `span` element could be styled with CSS `display: none` and the `nav` element would still have the label "You are here:".
+ It is also possible to reference an element using `aria-labelledby` even if that element is hidden. In the following example, the `span` element could be styled with CSS `display: none` and the `nav` element would still have the label "You are here:".
- <nav aria-labelledby="breadcrumbs-label">
- <span id="breadcrumbs-label">You are here:</span>
- <a href="/">Home</a> >
- <a href="/books/">Books</a> >
- <a>Children's books</a>
-</nav>
-
+ <nav aria-labelledby="breadcrumbs-label">
+ <span id="breadcrumbs-label">You are here:</span>
+ <a href="/">Home</a> >
+ <a href="/books/">Books</a> >
+ <a>Children's books</a>
+ </nav>
-
-
- Descriptions
-
- An element can be given an accessible description using the `aria-describedby` attribute or the `aria-details` attribute.
-
- The `aria-describedby` attribute works similarly to the `aria-labelledby` attribute. For example, a button could be described by a later paragraph.
-
- <button aria-describedby="trash-desc">Move to trash</button>
-...
-<p id="trash-desc">Items in the trash
-will be permanently removed after 30 days.</p>
-
- This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
-
- <button aria-describedby="trash-desc">
- Move to <img src="bin.svg" alt="trash">
-</button>
-...
-<p id="trash-desc">Items in <img src="bin.svg" alt="the trash">
-will be permanently removed after 30 days.</p>
-
- In some cases, a plain text description is insufficient. The `aria-details` attribute can be used in such situations. In this example, a text field for a passenger’s name (when booking a flight) has a description that is a list of three items, and contains a link to an external document with further details.
-
- <ul id="full-name-desc">
- <li>The passenger's name must match the name in their passport.</li>
- <li>The name must consist of only characters in the A-Z range.</li>
- <li><a href="faq.html#name">What if the name in the passport contains other characters?</a></li>
-</ul>
-<fieldset>
- <legend>Passenger 1 (adult)</legend>
- <p><label>Full name
- <input name="full-name" aria-details="full-name-desc">
- </label></p>
- ...
-</fieldset>
-
- If both `aria-details` and `aria-describedby` are specified on an element, only the `aria-details` attribute is used. This can be useful in order to provide a fallback for user agents that don’t support `aria-details`.
-
+
+
+ Describing Techniques
+
- Accessible description calculation
+ Describing by referencing content with aria-describedby
+ The `aria-describedby` attribute works similarly to the `aria-labelledby` attribute. For example, a button could be described by a later paragraph.
+
+ <button aria-describedby="trash-desc">Move to trash</button>
+ ...
+ <p id="trash-desc">Items in the trash
+ will be permanently removed after 30 days.</p>
+
+ This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
+
+ <button aria-describedby="trash-desc">
+ Move to <img src="bin.svg" alt="trash">
+ </button>
+ ...
+ <p id="trash-desc">Items in <img src="bin.svg" alt="the trash">
+ will be permanently removed after 30 days.</p>
+
+
+
+ Describing by referencing content with aria-details
>
+ In some cases, a plain text description is insufficient. The `aria-details` attribute can be used in such situations. In this example, a text field for a passenger’s name (when booking a flight) has a description that is a list of three items, and contains a link to an external document with further details.
+
+ <ul id="full-name-desc">
+ <li>The passenger's name must match the name in their passport.</li>
+ <li>The name must consist of only characters in the A-Z range.</li>
+ <li><a href="faq.html#name">What if the name in the passport contains other characters?</a></li>
+ </ul>
+ <fieldset>
+ <legend>Passenger 1 (adult)</legend>
+ <p><label>Full name
+ <input name="full-name" aria-details="full-name-desc">
+ </label></p>
+ ...
+ </fieldset>
+
+ If both `aria-details` and `aria-describedby` are specified on an element, only the `aria-details` attribute is used. This can be useful in order to provide a fallback for user agents that don’t support `aria-details`.
+
+
- Like the accessible name calculation (see the earlier section), the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
+
+ Accessible description calculation
- The accessible description calculation algorithm is the same algorithm as the accessible name calculation algorithm, but it branches off in some places depending on whether a name or a description is being calculated. In particular, when collecting an accessible description, the algorithm uses `aria-describedby` instead of `aria-labelledby`.
+ Like the accessible name calculation (see the earlier section), the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
- As with `aria-labelledby`, it is possible to reference an element using `aria-describedby` even if that element is hidden.
+ The accessible description calculation algorithm is the same algorithm as the accessible name calculation algorithm, but it branches off in some places depending on whether a name or a description is being calculated. In particular, when collecting an accessible description, the algorithm uses `aria-describedby` instead of `aria-labelledby`.
- For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. The description could also be referenced from the text field directly with `aria-describedby`. The accessible description for the `input` element is "Your username is the name that you use to log in to this service.".
+ As with `aria-labelledby`, it is possible to reference an element using `aria-describedby` even if that element is hidden.
- <label for="username">Username</label>
-<input id="username" name="username" aria-describedby="username-desc">
-<button aria-expanded="false" aria-controls="username-desc" aria-label="Help about username">?</button>
-<p id="username-desc" hidden>
- Your username is the name that you use to log in to this service.
-</p>
-
+ For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. The description could also be referenced from the text field directly with `aria-describedby`. The accessible description for the `input` element is "Your username is the name that you use to log in to this service.".
+
+ <label for="username">Username</label>
+ <input id="username" name="username" aria-describedby="username-desc">
+ <button aria-expanded="false" aria-controls="username-desc" aria-label="Help about username">?</button>
+ <p id="username-desc" hidden>
+ Your username is the name that you use to log in to this service.
+ </p>
diff --git a/draft-labelling-describing.md b/draft-labelling-describing.md
index 4b9713e14b..1b59826826 100644
--- a/draft-labelling-describing.md
+++ b/draft-labelling-describing.md
@@ -2,7 +2,7 @@
## Providing Accessible Names and Descriptions
-Providing elements with accessible names, and where appropriate, accessible descriptions is one of the most fundamental and important responsibilities authors have when developing accessible web experiences. While doing it well is not typically difficult, technical mistakes that have devistating impact are common. After providing some basic information about accessible names and descriptions, this section provides guidance for using the following ARIA properties:
+Providing elements with accessible names, and where appropriate, accessible descriptions is one of the most fundamental and important responsibilities authors have when developing accessible web experiences. While doing it well is not typically difficult, technical mistakes that can have devistating impacts are unfortunately common. After providing some basic information about accessible names and descriptions, this section provides guidance for using the following ARIA attributes:
### Accessible Name and Description Basics
From 16008f5c6484b87734ede1e2da4f270077278297 Mon Sep 17 00:00:00 2001
From: Matt King
Date: Tue, 7 May 2019 10:22:50 -0700
Subject: [PATCH 18/55] more rough draft work on intro content and overall
structure
---
aria-practices.html | 54 +++++++++++++++++++++++++++------------------
1 file changed, 33 insertions(+), 21 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index 9ebfae5dc6..1282b228e7 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3746,9 +3746,9 @@ What ARE Accessible Names and Descriptions?
How Are Name and Description Strings Derived?
- Because there are several elements and attributes for specifying text to include in an accessible name or description string, and because they can be combined in a practically endless number of ways, browsers have to implement a fairly complex algorithm for assembling the strings.
-The section on accessible name calculation provides a detailed explanation of the algorithm.
-However, most authors do not need a detailed understanding of the algorithm since nearly all elements can be named or described by implementing the coding patterns described in the naming techniques section and following the guidance provided by the cardinal rules for naming.
+ Because there are several elements and attributes for specifying text to include in an accessible name or description string, and because they can be combined in a practically endless number of ways, browsers implement fairly complex algorithms for assembling the strings.
+The sections on accessible name calculation and accessible description calculation provide detailed explanations of the algorithms.
+However, most authors do not need detailed understanding of the algorithms since nearly all circumstances where a name or description is useful are supported by the coding patterns described in the naming techniques and describing techniques sections.
@@ -3758,44 +3758,46 @@ Cardinal Rules of Naming
Rule 1: Heed Warnings and Test Thoroughly
- because the aria-label
and aria-labelledby
attributes override content contained in some elementss, they can block assistive technology access to some on-screen text.
- Thus
- , to both serve an optimal experience and avoid potentially disasterous mistakes, it is essential to understand when and how these two attributes override element text.
+ Several of the naming techniques include notes that warn against coding patterns that may appear logical at first glance but are either prohibitted by the ARIA specification or fall into gray space that is not yet fully specified.
+ These patterns may even yield desired names in some browsers.
+ However, it is unlikely they will provide consistent results across browsers, especially over time as work to improve the consistency of name calculation across browsers progresses.
+
+
+ In addition to heeding the warnings provided in the naming techniques, it is difficult to over emphasize the importance of testing to ensure that names browsers calculate match expectations.
- There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
-
- Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive technologies.
- Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
-
-
Rule 2: Prefer Visible Text
- When a user interface includes visible text that could be used to provide an appropriate accessible name, using the visible text for the accessible name simplifies maintenance, prevents bugs, and reduces language translation requirements, which leads to a more robust accessible experience.
- The naming techniques described in the sections below emphasize techniques for utilizing on-screen text.
+ When a user interface includes visible text that could be used to provide an appropriate accessible name, using the visible text for the accessible name simplifies maintenance, prevents bugs, and reduces language translation requirements.
+ When names are generated from text that exists only in markup and is never displayed visually, there is a greater likelihood that accessible names are not updated when the user interface design or content are changed.
Rule 3: Prefer Native Techniques
- That is, in HTML documents, prefer HTML naming techniques, such as the HTML label element.
+
+ In HTML documents, whenever possible, rely on HTML naming techniques, such as the HTML label element.
+ While less flexible, their simplicity and reliance on visible text help ensure robust accessible experiences.
+
+
Rule 4: Avoid Browser Fallback
- Talk about how fallbacks can be less robust because of potential implementation inconsistency.
- title and placeholder
+ When authors do not specify an accessible name using an element or attribute that is intended for naming, browsers attempt to help assistive technology users by resorting to fall back methods for generating a name.
+ For example, the HTML title and placeholder attributes are used as last resort sources for accessible names.
+ Because the purpose of these attributes is not naming, their content typically yields low quality accessible names that are not effective.
Rule 5: Compose Brief, Useful Names
- Mention some good properties of names, such as uniqueness, brevity, and clarity.
- Refer user to section on best practices for composing effective accessible names.
- Example practice: Do NOT include a WAI-ARIA role name in the accessible name. For example, do not include the word "button" in the name of a button or the word "navigation" in the name of a navigation region.
+ In the same way that visually crowded screens reduce usability, excessively long or insufficiently distinct and descriptive accessible names can make a user interface very difficult, or even impossible, to use for someone who relies on a non-visual form of the user interface.
+ In other words, for a web experience to accessible, the names must be effective.
+ Composing Effective and User-friendly Accessible Names
@@ -3837,6 +3839,15 @@ Naming with Child Content
Naming with a String Attribute Via aria-label
+
+ because the aria-label
and aria-labelledby
attributes override content contained in some elementss, they can block assistive technology access to some on-screen text.
+ Thus, to both serve an optimal experience and avoid potentially disasterous mistakes, it is essential to understand when and how these two attributes override element text.
+
+ There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
+
+ Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive technologies.
+ Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
+
If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
@@ -3898,9 +3909,10 @@ Label that augments the element
-
+
Composing Effective and User-friendly Accessible Names
Todo: Write a section that describes how to make good names, i.e., brief, descriptive, unique, front-loaded, no role names, etc.
+ Example practice: Do NOT include a WAI-ARIA role name in the accessible name. For example, do not include the word "button" in the name of a button or the word "navigation" in the name of a navigation region.
From 0f0524ff2ea694cb59b4ffb9c40f5e8478c65e53 Mon Sep 17 00:00:00 2001
From: Matt King
Date: Thu, 9 May 2019 16:38:02 -0700
Subject: [PATCH 19/55] edits to cardinal rules
---
aria-practices.html | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index 1282b228e7..e39cba3007 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3723,10 +3723,10 @@ What ARE Accessible Names and Descriptions?
An accessible name is a short string, typically 1 to 3 words, that authors associate with an element to provide users of assistive technologies with a label for the element.
For example, an input field might have an accessible name of "User ID" or a button might be named "Submit".
- An accessible name serves two primary purposes:
+ An accessible name serves two primary purposes for users of assistive technologies, such as screen readers:
Convey the purpose or intent of the element.
- Distinguish it from other elements on the page.
+ Distinguishes an element from other elements on the page.
Both the WAI-ARIA specification and WCAG require all focusable, interactive elements to have an accessible name.
@@ -3758,8 +3758,8 @@
Cardinal Rules of Naming
Rule 1: Heed Warnings and Test Thoroughly
- Several of the naming techniques include notes that warn against coding patterns that may appear logical at first glance but are either prohibitted by the ARIA specification or fall into gray space that is not yet fully specified.
- These patterns may even yield desired names in some browsers.
+ Several of the below naming techniques include notes that warn against specific coding patterns that are either prohibitted by the ARIA specification or fall into gray space that is not yet fully specified.
+ Some of these prohibitted or ambiguous patterns may appear logical and even yield desired names in some browsers.
However, it is unlikely they will provide consistent results across browsers, especially over time as work to improve the consistency of name calculation across browsers progresses.
@@ -3787,7 +3787,7 @@
Rule 3: Prefer Native Techniques
Rule 4: Avoid Browser Fallback
When authors do not specify an accessible name using an element or attribute that is intended for naming, browsers attempt to help assistive technology users by resorting to fall back methods for generating a name.
- For example, the HTML title and placeholder attributes are used as last resort sources for accessible names.
+ For example, the HTML title and placeholder attributes are used as last resort sources of content for accessible names.
Because the purpose of these attributes is not naming, their content typically yields low quality accessible names that are not effective.
@@ -3797,7 +3797,7 @@ Rule 5: Compose Brief, Useful Names
In the same way that visually crowded screens reduce usability, excessively long or insufficiently distinct and descriptive accessible names can make a user interface very difficult, or even impossible, to use for someone who relies on a non-visual form of the user interface.
In other words, for a web experience to accessible, the names must be effective.
- Composing Effective and User-friendly Accessible Names
+ The below section on Composing Effective and User-friendly Accessible Names provides guidance for striking an effective balance between brevity and descriptiveness.
@@ -3813,7 +3813,7 @@ Naming with Child Content
This could be rendered to assistive technology as "link, Home"; the role and the label, not not repeating the content ("link, Home, Home").
- The following roles get the label from the contents by default:
+ Elements having one of the following roles are, by default, named by the content they contain:
`button`
`cell`
@@ -3828,7 +3828,6 @@ Naming with Child Content
`option`
`radio`
`row`
- `rowgroup`
`rowheader`
`switch`
`tab`
From e131ba5df38ddeed413fbfcee9baea56a4a2e4d9 Mon Sep 17 00:00:00 2001
From: Matt King
Date: Sat, 11 May 2019 14:03:33 -0700
Subject: [PATCH 20/55] Adjust IA
---
aria-practices.html | 574 ++++++++++++++++++++++----------------------
1 file changed, 288 insertions(+), 286 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index e39cba3007..f394ad8bcd 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3746,319 +3746,321 @@ What ARE Accessible Names and Descriptions?
How Are Name and Description Strings Derived?
- Because there are several elements and attributes for specifying text to include in an accessible name or description string, and because they can be combined in a practically endless number of ways, browsers implement fairly complex algorithms for assembling the strings.
+ Because there are several elements and attributes for specifying text to include in an accessible name or description string, and because authors can combine them in a practically endless number of ways, browsers implement fairly complex algorithms for assembling the strings.
The sections on accessible name calculation and accessible description calculation provide detailed explanations of the algorithms.
However, most authors do not need detailed understanding of the algorithms since nearly all circumstances where a name or description is useful are supported by the coding patterns described in the naming techniques and describing techniques sections.
-
- Cardinal Rules of Naming
-
-
- Rule 1: Heed Warnings and Test Thoroughly
-
- Several of the below naming techniques include notes that warn against specific coding patterns that are either prohibitted by the ARIA specification or fall into gray space that is not yet fully specified.
- Some of these prohibitted or ambiguous patterns may appear logical and even yield desired names in some browsers.
- However, it is unlikely they will provide consistent results across browsers, especially over time as work to improve the consistency of name calculation across browsers progresses.
-
-
- In addition to heeding the warnings provided in the naming techniques, it is difficult to over emphasize the importance of testing to ensure that names browsers calculate match expectations.
-
-
-
-
- Rule 2: Prefer Visible Text
-
- When a user interface includes visible text that could be used to provide an appropriate accessible name, using the visible text for the accessible name simplifies maintenance, prevents bugs, and reduces language translation requirements.
- When names are generated from text that exists only in markup and is never displayed visually, there is a greater likelihood that accessible names are not updated when the user interface design or content are changed.
-
-
-
-
- Rule 3: Prefer Native Techniques
-
- In HTML documents, whenever possible, rely on HTML naming techniques, such as the HTML label element.
- While less flexible, their simplicity and reliance on visible text help ensure robust accessible experiences.
-
-
-
-
- Rule 4: Avoid Browser Fallback
-
- When authors do not specify an accessible name using an element or attribute that is intended for naming, browsers attempt to help assistive technology users by resorting to fall back methods for generating a name.
- For example, the HTML title and placeholder attributes are used as last resort sources of content for accessible names.
- Because the purpose of these attributes is not naming, their content typically yields low quality accessible names that are not effective.
-
-
-
-
- Rule 5: Compose Brief, Useful Names
-
- In the same way that visually crowded screens reduce usability, excessively long or insufficiently distinct and descriptive accessible names can make a user interface very difficult, or even impossible, to use for someone who relies on a non-visual form of the user interface.
- In other words, for a web experience to accessible, the names must be effective.
- The below section on Composing Effective and User-friendly Accessible Names provides guidance for striking an effective balance between brevity and descriptiveness.
-
+
+ Accessible Names
+
+ Cardinal Rules of Naming
+
+
+ Rule 1: Heed Warnings and Test Thoroughly
+
+ Several of the below naming techniques include notes that warn against specific coding patterns that are either prohibitted by the ARIA specification or fall into gray space that is not yet fully specified.
+ Some of these prohibitted or ambiguous patterns may appear logical and even yield desired names in some browsers.
+ However, it is unlikely they will provide consistent results across browsers, especially over time as work to improve the consistency of name calculation across browsers progresses.
+
+
+ In addition to heeding the warnings provided in the naming techniques, it is difficult to over emphasize the importance of testing to ensure that names browsers calculate match expectations.
+
+
+
+
+ Rule 2: Prefer Visible Text
+
+ When a user interface includes visible text that could be used to provide an appropriate accessible name, using the visible text for the accessible name simplifies maintenance, prevents bugs, and reduces language translation requirements.
+ When names are generated from text that exists only in markup and is never displayed visually, there is a greater likelihood that accessible names are not updated when the user interface design or content are changed.
+
+
+
+
+ Rule 3: Prefer Native Techniques
+
+ In HTML documents, whenever possible, rely on HTML naming techniques, such as the HTML label element.
+ While less flexible, their simplicity and reliance on visible text help ensure robust accessible experiences.
+
+
+
+
+ Rule 4: Avoid Browser Fallback
+
+ When authors do not specify an accessible name using an element or attribute that is intended for naming, browsers attempt to help assistive technology users by resorting to fall back methods for generating a name.
+ For example, the HTML title and placeholder attributes are used as last resort sources of content for accessible names.
+ Because the purpose of these attributes is not naming, their content typically yields low quality accessible names that are not effective.
+
+
+
+
+ Rule 5: Compose Brief, Useful Names
+
+ In the same way that visually crowded screens reduce usability, excessively long or insufficiently distinct and descriptive accessible names can make a user interface very difficult, or even impossible, to use for someone who relies on a non-visual form of the user interface.
+ In other words, for a web experience to accessible, the names must be effective.
+ The below section on Composing Effective and User-friendly Accessible Names provides guidance for striking an effective balance between brevity and descriptiveness.
+
+
-
-
-
- Naming Techniques
-
-
- Naming with Child Content
- For elements with certain roles, the label is taken from the element’s contents by default, and the label will represent the element when communicated to assistive technologies. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
-
- <a href="/">Home</a>
-
- This could be rendered to assistive technology as "link, Home"; the role and the label, not not repeating the content ("link, Home, Home").
- Elements having one of the following roles are, by default, named by the content they contain:
+
+ Naming Techniques
+
+
+ Naming with Child Content
+ For elements with certain roles, the label is taken from the element’s contents by default, and the label will represent the element when communicated to assistive technologies. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
+
+ <a href="/">Home</a>
+
+ This could be rendered to assistive technology as "link, Home"; the role and the label, not not repeating the content ("link, Home, Home").
+
+ Elements having one of the following roles are, by default, named by the content they contain:
+
+ `button`
+ `cell`
+ `checkbox`
+ `columnheader`
+ `gridcell`
+ `heading`
+ `link`
+ `menuitem`
+ `menuitemcheckbox`
+ `menuitemradio`
+ `option`
+ `radio`
+ `row`
+ `rowheader`
+ `switch`
+ `tab`
+ `tooltip`
+ `treeitem`
+
+
+
+
+ Naming with a String Attribute Via aria-label
+
+ because the aria-label
and aria-labelledby
attributes override content contained in some elementss, they can block assistive technology access to some on-screen text.
+ Thus, to both serve an optimal experience and avoid potentially disasterous mistakes, it is essential to understand when and how these two attributes override element text.
+
+ There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
- `button`
- `cell`
- `checkbox`
- `columnheader`
- `gridcell`
- `heading`
- `link`
- `menuitem`
- `menuitemcheckbox`
- `menuitemradio`
- `option`
- `radio`
- `row`
- `rowheader`
- `switch`
- `tab`
- `tooltip`
- `treeitem`
+ Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive technologies.
+ Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
+ If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
+
+ In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
+
+ <button type="button" aria-label="Close">X</button>
+
+
+ Naming with Referenced Content Via aria-labeledby
+ If the element’s contents are not appropriate as a label, but there is an element that can be used as the label, then use the `aria-labelledby` attribute.
+
+ In the following example, an element with the "switch" role is labeled by a previous sibling element.
+
+ <span id="night-mode-label">Night mode</span>
+ <span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span>
+
+ Because a `span` element is used for the switch control, the HTML `label` element cannot be used to label it, since it only works with HTML elements that are form controls. However, the `switch` role can be used on an `input` element with `type="checkbox”`, and then HTML `label` can be used.
+
+ <label for="night-mode">Night mode</label>
+ <input type="checkbox" role="switch" id="night-mode">
+
+ In some cases, the combination of the element’s contents and another element would be appropriate as a label. In such situations, use the `aria-labelledby` and reference both the element itself and the other element.
+
+ In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
+
+ <h2 id="bees-heading">7 ways you can help save the bees</h2>
+ <p>Bees are disappearing rapidly.
+ Here are seven things you can do to help.</p>
+ <p><a id="bees-read-more" aria-labelledby="bees-read-more bees-heading">Read more...</a></p>
+
+
+
+ Label that augments the element
+
+ Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. For elements with these roles, a label augments the element, but does not override the contents.
+
+ Examples of such roles are (note that this is not a complete list):
+
+
+ `alertdialog`
+ `application`
+ `article`
+ `banner`
+ `complementary`
+ `navigation`
+ `radiogroup`
+ `search`
+ `status`
+
+
+ For example, the `navigation` landmark could be labeled with the purpose of the landmark. In the following snippet, a "breadcrumbs"
+ navigation region is labeled explicitly using the `aria-labelledby` attribute. The HTML `nav` element has the `navigation` role by default.
+
+ <nav aria-labelledby="breadcrumbs-label">
+ <span id="breadcrumbs-label">You are here:</span>
+ <a href="/">Home</a> >
+ <a href="/books/">Books</a> >
+ <a>Children's books</a>
+ </nav>
+
-
- Naming with a String Attribute Via aria-label
-
- because the aria-label
and aria-labelledby
attributes override content contained in some elementss, they can block assistive technology access to some on-screen text.
- Thus, to both serve an optimal experience and avoid potentially disasterous mistakes, it is essential to understand when and how these two attributes override element text.
-
- There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
-
- Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive technologies.
- Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
-
- If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
-
- In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
-
- <button type="button" aria-label="Close">X</button>
+
+ Composing Effective and User-friendly Accessible Names
+ Todo: Write a section that describes how to make good names, i.e., brief, descriptive, unique, front-loaded, no role names, etc.
+ Example practice: Do NOT include a WAI-ARIA role name in the accessible name. For example, do not include the word "button" in the name of a button or the word "navigation" in the name of a navigation region.
-
- Naming with Referenced Content Via aria-labeledby
- If the element’s contents are not appropriate as a label, but there is an element that can be used as the label, then use the `aria-labelledby` attribute.
-
- In the following example, an element with the "switch" role is labeled by a previous sibling element.
-
- <span id="night-mode-label">Night mode</span>
-<span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span>
-
- Because a `span` element is used for the switch control, the HTML `label` element cannot be used to label it, since it only works with HTML elements that are form controls. However, the `switch` role can be used on an `input` element with `type="checkbox”`, and then HTML `label` can be used.
-
- <label for="night-mode">Night mode</label>
-<input type="checkbox" role="switch" id="night-mode">
-
- In some cases, the combination of the element’s contents and another element would be appropriate as a label. In such situations, use the `aria-labelledby` and reference both the element itself and the other element.
-
- In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
-
- <h2 id="bees-heading">7 ways you can help save the bees</h2>
-<p>Bees are disappearing rapidly.
-Here are seven things you can do to help.</p>
-<p><a id="bees-read-more" aria-labelledby="bees-read-more bees-heading">Read more...</a></p>
-
-
-
- Label that augments the element
-
- Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. For elements with these roles, a label augments the element, but does not override the contents.
-
- Examples of such roles are (note that this is not a complete list):
-
+
+
+ Accessible Name Guidance by Role
+ Todo: build a table with every concrete role with columns for:
- `alertdialog`
- `application`
- `article`
- `banner`
- `complementary`
- `navigation`
- `radiogroup`
- `search`
- `status`
+ role
+ Name Required?: with values of always, sometimes, or never
+ Named by Content?: values of Yes or No
+ Guidance: Explains sometimes and never for name required. Provides warning if named from content.
-
- For example, the `navigation` landmark could be labeled with the purpose of the landmark. In the following snippet, a "breadcrumbs"
- navigation region is labeled explicitly using the `aria-labelledby` attribute. The HTML `nav` element has the `navigation` role by default.
-
- <nav aria-labelledby="breadcrumbs-label">
- <span id="breadcrumbs-label">You are here:</span>
- <a href="/">Home</a> >
- <a href="/books/">Books</a> >
- <a>Children's books</a>
-</nav>
+
+
+
+ Accessible name calculation
+ User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
+ User agents attempt to formulate labels for elements by walking through a list of potential naming methods and use the first that generates a name. The algorithm is roughly like this:
+
+ First, the `aria-labelledby` attribute is used if present.
+ If the label is still empty, the `aria-label` attribute is used if present.
+ If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
+ If the label is still empty, then for roles that can take label from the element's content, the element’s contents.
+ Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
+
+
+ The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
+
+ For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
+
+
+ Examples of non-recursive accessible name calculation
+
+ For example, an img element with just a src attribute has no label (don’t do this):
+
+ <img src="photo.jpg">
+
+ If there is a `title` attribute, then that is used as the label (fallback mechanism; generally avoid doing this):
+
+ <img src="photo.jpg" title="The Queen, holding a pigeon.">
+
+ If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
+
+ <img src="photo.jpg" alt="The Queen, holding a pigeon." title="Photo: Rex Features">
+
+ If there is also an `aria-label` attribute, then that overrides the `alt` attribute:
+
+ <img src="photo.jpg" aria-label="The Queen, holding a pigeon." title="Photo: Rex Features"
+ alt="Sorry, this image failed to load.">
+
+ If there is also an `aria-labelledby` attribute, that wins over the other attributes (the `aria-label` attribute ought to be removed if it is not used):
+
+ <img src="photo.jpg" aria-label="This is ignored." title="Photo: Established Depiction"
+ alt="Sorry, this image failed to load." aria-labelledby="the-queen">
+ <span id="the-queen">The Queen, holding a pigeon.</span>
+
+
+
+ Examples of recursive accessible name calculation
+
+ The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
+
+ In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
+
+ <button>Move to <img src="bin.svg" alt="trash"></button>
+
+ When following an `aria-labelledby` reference, the algorithm avoids following the same reference twice in order to not end up in infinite loops.
+
+ In this example, the label for the button is computed by first following the `aria-labelledby` reference to the parent element, and then computing the label for that element from the child nodes, first visiting the `button` element again but ignoring the `aria-labelledby` reference and instead using the `aria-label` attribute, and then visiting the next child (the text node). The resulting label is "Remove meeting: Daily status report".
+
+ <div id="meeting-1">
+ <button aria-labelledby="meeting-1"
+ aria-label="Remove meeting:">X</button>
+ Daily status report
+ </div>
+
+ It is also possible to reference an element using `aria-labelledby` even if that element is hidden. In the following example, the `span` element could be styled with CSS `display: none` and the `nav` element would still have the label "You are here:".
+
+ <nav aria-labelledby="breadcrumbs-label">
+ <span id="breadcrumbs-label">You are here:</span>
+ <a href="/">Home</a> >
+ <a href="/books/">Books</a> >
+ <a>Children's books</a>
+ </nav>
+
-
- Composing Effective and User-friendly Accessible Names
- Todo: Write a section that describes how to make good names, i.e., brief, descriptive, unique, front-loaded, no role names, etc.
- Example practice: Do NOT include a WAI-ARIA role name in the accessible name. For example, do not include the word "button" in the name of a button or the word "navigation" in the name of a navigation region.
-
+
+ Accessible Descriptions
+
+ Describing Techniques
+
+
+ Describing by referencing content with aria-describedby
+ The `aria-describedby` attribute works similarly to the `aria-labelledby` attribute. For example, a button could be described by a later paragraph.
-
- Accessible Name Guidance by Role
- Todo: build a table with every concrete role with columns for:
-
- role
- Name Required?: with values of always, sometimes, or never
- Named by Content?: values of Yes or No
- Guidance: Explains sometimes and never for name required. Provides warning if named from content.
-
-
+ <button aria-describedby="trash-desc">Move to trash</button>
+ ...
+ <p id="trash-desc">Items in the trash
+ will be permanently removed after 30 days.</p>
-
- Accessible name calculation
- User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
- User agents attempt to formulate labels for elements by walking through a list of potential naming methods and use the first that generates a name. The algorithm is roughly like this:
-
- First, the `aria-labelledby` attribute is used if present.
- If the label is still empty, the `aria-label` attribute is used if present.
- If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
- If the label is still empty, then for roles that can take label from the element's content, the element’s contents.
- Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
-
-
- The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
-
- For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
-
-
- Examples of non-recursive accessible name calculation
-
- For example, an img element with just a src attribute has no label (don’t do this):
-
- <img src="photo.jpg">
-
- If there is a `title` attribute, then that is used as the label (fallback mechanism; generally avoid doing this):
-
- <img src="photo.jpg" title="The Queen, holding a pigeon.">
-
- If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
-
- <img src="photo.jpg" alt="The Queen, holding a pigeon." title="Photo: Rex Features">
-
- If there is also an `aria-label` attribute, then that overrides the `alt` attribute:
-
- <img src="photo.jpg" aria-label="The Queen, holding a pigeon." title="Photo: Rex Features"
- alt="Sorry, this image failed to load.">
-
- If there is also an `aria-labelledby` attribute, that wins over the other attributes (the `aria-label` attribute ought to be removed if it is not used):
-
- <img src="photo.jpg" aria-label="This is ignored." title="Photo: Established Depiction"
- alt="Sorry, this image failed to load." aria-labelledby="the-queen">
- <span id="the-queen">The Queen, holding a pigeon.</span>
+ This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
+
+ <button aria-describedby="trash-desc">
+ Move to <img src="bin.svg" alt="trash">
+ </button>
+ ...
+ <p id="trash-desc">Items in <img src="bin.svg" alt="the trash">
+ will be permanently removed after 30 days.</p>
-
+
- Examples of recursive accessible name calculation
-
- The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
-
- In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
-
- <button>Move to <img src="bin.svg" alt="trash"></button>
-
- When following an `aria-labelledby` reference, the algorithm avoids following the same reference twice in order to not end up in infinite loops.
-
- In this example, the label for the button is computed by first following the `aria-labelledby` reference to the parent element, and then computing the label for that element from the child nodes, first visiting the `button` element again but ignoring the `aria-labelledby` reference and instead using the `aria-label` attribute, and then visiting the next child (the text node). The resulting label is "Remove meeting: Daily status report".
-
- <div id="meeting-1">
- <button aria-labelledby="meeting-1"
- aria-label="Remove meeting:">X</button>
- Daily status report
- </div>
-
- It is also possible to reference an element using `aria-labelledby` even if that element is hidden. In the following example, the `span` element could be styled with CSS `display: none` and the `nav` element would still have the label "You are here:".
-
- <nav aria-labelledby="breadcrumbs-label">
- <span id="breadcrumbs-label">You are here:</span>
- <a href="/">Home</a> >
- <a href="/books/">Books</a> >
- <a>Children's books</a>
- </nav>
-
-
+ Describing by referencing content with aria-details
+ In some cases, a plain text description is insufficient. The `aria-details` attribute can be used in such situations. In this example, a text field for a passenger’s name (when booking a flight) has a description that is a list of three items, and contains a link to an external document with further details.
-
- Describing Techniques
-
-
- Describing by referencing content with aria-describedby
- The `aria-describedby` attribute works similarly to the `aria-labelledby` attribute. For example, a button could be described by a later paragraph.
-
- <button aria-describedby="trash-desc">Move to trash</button>
- ...
- <p id="trash-desc">Items in the trash
- will be permanently removed after 30 days.</p>
-
- This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
-
- <button aria-describedby="trash-desc">
- Move to <img src="bin.svg" alt="trash">
- </button>
- ...
- <p id="trash-desc">Items in <img src="bin.svg" alt="the trash">
- will be permanently removed after 30 days.</p>
-
+ <ul id="full-name-desc">
+ <li>The passenger's name must match the name in their passport.</li>
+ <li>The name must consist of only characters in the A-Z range.</li>
+ <li><a href="faq.html#name">What if the name in the passport contains other characters?</a></li>
+ </ul>
+ <fieldset>
+ <legend>Passenger 1 (adult)</legend>
+ <p><label>Full name
+ <input name="full-name" aria-details="full-name-desc">
+ </label></p>
+ ...
+ </fieldset>
-
- Describing by referencing content with aria-details
>
- In some cases, a plain text description is insufficient. The `aria-details` attribute can be used in such situations. In this example, a text field for a passenger’s name (when booking a flight) has a description that is a list of three items, and contains a link to an external document with further details.
+ If both `aria-details` and `aria-describedby` are specified on an element, only the `aria-details` attribute is used. This can be useful in order to provide a fallback for user agents that don’t support `aria-details`.
+
+
- <ul id="full-name-desc">
- <li>The passenger's name must match the name in their passport.</li>
- <li>The name must consist of only characters in the A-Z range.</li>
- <li><a href="faq.html#name">What if the name in the passport contains other characters?</a></li>
- </ul>
- <fieldset>
- <legend>Passenger 1 (adult)</legend>
- <p><label>Full name
- <input name="full-name" aria-details="full-name-desc">
- </label></p>
- ...
- </fieldset>
+
+ Accessible description calculation
+ Like the accessible name calculation (see the earlier section), the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
+ The accessible description calculation algorithm is the same algorithm as the accessible name calculation algorithm, but it branches off in some places depending on whether a name or a description is being calculated. In particular, when collecting an accessible description, the algorithm uses `aria-describedby` instead of `aria-labelledby`.
+ As with `aria-labelledby`, it is possible to reference an element using `aria-describedby` even if that element is hidden.
+ For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. The description could also be referenced from the text field directly with `aria-describedby`. The accessible description for the `input` element is "Your username is the name that you use to log in to this service.".
- If both `aria-details` and `aria-describedby` are specified on an element, only the `aria-details` attribute is used. This can be useful in order to provide a fallback for user agents that don’t support `aria-details`.
+ <label for="username">Username</label>
+ <input id="username" name="username" aria-describedby="username-desc">
+ <button aria-expanded="false" aria-controls="username-desc" aria-label="Help about username">?</button>
+ <p id="username-desc" hidden>
+ Your username is the name that you use to log in to this service.
+ </p>
-
-
- Accessible description calculation
-
- Like the accessible name calculation (see the earlier section), the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
-
- The accessible description calculation algorithm is the same algorithm as the accessible name calculation algorithm, but it branches off in some places depending on whether a name or a description is being calculated. In particular, when collecting an accessible description, the algorithm uses `aria-describedby` instead of `aria-labelledby`.
-
- As with `aria-labelledby`, it is possible to reference an element using `aria-describedby` even if that element is hidden.
-
- For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. The description could also be referenced from the text field directly with `aria-describedby`. The accessible description for the `input` element is "Your username is the name that you use to log in to this service.".
-
- <label for="username">Username</label>
- <input id="username" name="username" aria-describedby="username-desc">
- <button aria-expanded="false" aria-controls="username-desc" aria-label="Help about username">?</button>
- <p id="username-desc" hidden>
- Your username is the name that you use to log in to this service.
- </p>
-
From a40f81b940a0f27e115162f6b0e8dc735b66718e Mon Sep 17 00:00:00 2001
From: Matt King
Date: Sat, 11 May 2019 17:08:36 -0700
Subject: [PATCH 21/55] Editorial revisions to name from content
---
aria-practices.html | 57 +++++++++++++++++++++++++++------------------
1 file changed, 34 insertions(+), 23 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index f394ad8bcd..908a10c97d 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3809,33 +3809,44 @@ Naming Techniques
Naming with Child Content
- For elements with certain roles, the label is taken from the element’s contents by default, and the label will represent the element when communicated to assistive technologies. In the following example, a link (with default role `link`) gets its label from the element’s contents ("Home").
-
+
+ There are certain elements that get their name from the content they contain.
+ For example, the following link is named "Home".
+
+
<a href="/">Home</a>
- This could be rendered to assistive technology as "link, Home"; the role and the label, not not repeating the content ("link, Home, Home").
-
- Elements having one of the following roles are, by default, named by the content they contain:
+
+ When assistive technologies render an element, such as a link or button, that gets its accessible name from its content, the accessible name is the only content the user can perceive for that element.
+ This is in contrast to other elements, such as text fields or tables, where the accessible name is a label that is presented along with the value or content of the element.
+ For instance, the accessible name of a table can be derived from a caption element, and assistive technologies render both the caption and all other content contained inside the table.
+
+ Elements having one of the following roles are, by default, named by a string calculated from all their descendant content:
- `button`
- `cell`
- `checkbox`
- `columnheader`
- `gridcell`
- `heading`
- `link`
- `menuitem`
- `menuitemcheckbox`
- `menuitemradio`
- `option`
- `radio`
- `row`
- `rowheader`
- `switch`
- `tab`
- `tooltip`
- `treeitem`
+ button
+ cell
+ checkbox
+ columnheader
+ gridcell
+ heading
+ link
+ menuitem
+ menuitemcheckbox
+ menuitemradio
+ option
+ radio
+ row
+ rowheader
+ switch
+ tab
+ tooltip
+ treeitem
+
+ WARNING! If an element with one of the above roles is named by using aria-label
or aria-labelledby
, text content contained in the element and its descendants is hidden from assistive technology users unless the descendant content is referenced by aria-labelledby
.
+ It is strongly recommended to avoid using either of these attributes to override content of one of the above elements except in rare circumstances where hiding content from assistive technology users is beneficial.
+ In addition, in situations where visible content is hidden from assistive technology users by use of one of these attributes, thorough testing with assistive technologies is particularly important.
+
From 93c9ec7f6ee65fdb2259f2a85376be360381d093 Mon Sep 17 00:00:00 2001
From: Matt King
Date: Sun, 12 May 2019 10:06:43 -0700
Subject: [PATCH 22/55] Editorial revisions to aria-label section
---
aria-practices.html | 51 ++++++++++++++++++++++++++++++++-------------
1 file changed, 36 insertions(+), 15 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index 908a10c97d..ff9f3719b3 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3807,7 +3807,7 @@ Rule 5: Compose Brief, Useful Names
Naming Techniques
-
+
Naming with Child Content
There are certain elements that get their name from the content they contain.
@@ -3849,24 +3849,45 @@
Naming with Child Content
-
+
Naming with a String Attribute Via aria-label
- because the aria-label
and aria-labelledby
attributes override content contained in some elementss, they can block assistive technology access to some on-screen text.
- Thus, to both serve an optimal experience and avoid potentially disasterous mistakes, it is essential to understand when and how these two attributes override element text.
+ The aria-label attribute enables authors to specify a string that will name an element.
+ For example, the name of the following button is "Close".
- There are two different kinds of labels, depending on the element’s role. The difference is both in how the label is computed for the element, and how the element is represented to assistive technologies.
-
- Label that represents the element. The label is taken from the element's contents, unless `aria-labelledby` or `aria-label` attributes are used. Only the label is represented to users of assistive technologies.
- Label that augments the element. The label is not taken from the element's contents (by default). A label can be set using `aria-labelledby` or `aria-label`. The label will augment the element; both the label and the element's contents are exposed to users of assistive technology.
-
- If there is no content that is appropriate to use as the label, then use the `aria-label` attribute to set the label for the element directly.
-
- In the following example, a close button contains an "X" and is given the label “Close” using the `aria-label` attribute.
-
<button type="button" aria-label="Close">X</button>
+
+ The aria-label
attribute is useful when there is no visible text content that will serve as an appropriate accessible name.
+
+
+ The aria-label
attribute effects assistive technology users in one of two different ways, depending on the role of the element to which it is applied.
+ When applied to an element with one of the roles that supports naming from child content , aria-label
hides descendant content from assistive technology users and replaces the content with the value of aria-label
.
+ However, when applied to nearly any other type of element, assistive technologies will render both the value of aria-label and the content of the element.
+ For example, the name of the following navigation region is "Product".
+
+
+ <nav aria-label="Product">
+ <!-- list of navigation links to product pages -->
+ </nav>
+
+
+ When encountering this navigation region, a screen reader user will hear the name and role of the element, e.g., "Product navigation region", and then be able to read through the links contained in the region.
+
+
+
Warnings!
+
+ There are certain types of elements that should not be named with aria-label
. They are identified in the table in section Accessible Name Guidance by Role .
+
+ If aria-label
is applied to an element with one of the roles that supports naming from child content , text content contained in the element and its descendants is hidden from assistive technology users.
+ It is strongly recommended to avoid using this attribute to override content of one of these elements except in rare circumstances where hiding content from assistive technology users is beneficial.
+
+ Because the value of aria-label
is not rendered visually, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
+ When a user interface is translated into multiple languages, ensure that aria-lable
values are translated.
+
+
-
+
+
Naming with Referenced Content Via aria-labeledby
If the element’s contents are not appropriate as a label, but there is an element that can be used as the label, then use the `aria-labelledby` attribute.
@@ -3889,7 +3910,7 @@ Naming with Referenced Content Via aria-labeledby
Here are seven things you can do to help.</p>
<p><a id="bees-read-more" aria-labelledby="bees-read-more bees-heading">Read more...</a></p>
-
+
Label that augments the element
From 9276759ee0d054d99c7fd8a0ef3695c4c99b040d Mon Sep 17 00:00:00 2001
From: Matt King
Date: Sun, 12 May 2019 14:25:45 -0700
Subject: [PATCH 23/55] Editorial revision to aria-labelledby section
---
aria-practices.html | 133 ++++++++++++++++++++++----------------------
1 file changed, 66 insertions(+), 67 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index ff9f3719b3..ce20749ee1 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3726,7 +3726,7 @@ What ARE Accessible Names and Descriptions?
An accessible name serves two primary purposes for users of assistive technologies, such as screen readers:
Convey the purpose or intent of the element.
- Distinguishes an element from other elements on the page.
+ Distinguish the element from other elements on the page.
Both the WAI-ARIA specification and WCAG require all focusable, interactive elements to have an accessible name.
@@ -3842,8 +3842,8 @@
Naming with Child Content
tooltip
treeitem
-
- WARNING! If an element with one of the above roles is named by using aria-label
or aria-labelledby
, text content contained in the element and its descendants is hidden from assistive technology users unless the descendant content is referenced by aria-labelledby
.
+
+ If an element with one of the above roles is named by using aria-label
or aria-labelledby
, text content contained in the element and its descendants is hidden from assistive technology users unless the descendant content is referenced by aria-labelledby
.
It is strongly recommended to avoid using either of these attributes to override content of one of the above elements except in rare circumstances where hiding content from assistive technology users is beneficial.
In addition, in situations where visible content is hidden from assistive technology users by use of one of these attributes, thorough testing with assistive technologies is particularly important.
@@ -3873,72 +3873,71 @@ Naming with a String Attribute Via aria-label
When encountering this navigation region, a screen reader user will hear the name and role of the element, e.g., "Product navigation region", and then be able to read through the links contained in the region.
-
-
Warnings!
-
- There are certain types of elements that should not be named with aria-label
. They are identified in the table in section Accessible Name Guidance by Role .
-
- If aria-label
is applied to an element with one of the roles that supports naming from child content , text content contained in the element and its descendants is hidden from assistive technology users.
- It is strongly recommended to avoid using this attribute to override content of one of these elements except in rare circumstances where hiding content from assistive technology users is beneficial.
-
- Because the value of aria-label
is not rendered visually, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
- When a user interface is translated into multiple languages, ensure that aria-lable
values are translated.
-
-
+
+
+ If aria-label
is applied to an element with one of the roles that supports naming from child content , text content contained in the element and its descendants is hidden from assistive technology users.
+ It is strongly recommended to avoid using this attribute to override content of one of these elements except in rare circumstances where hiding content from assistive technology users is beneficial.
+
+ There are certain types of elements, such as paragraphs and list items, that should not be named with aria-label
. They are identified in the table in section Accessible Name Guidance by Role .
+ Because the value of aria-label
is not rendered visually, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
+ When a user interface is translated into multiple languages, ensure that aria-lable
values are translated.
+
Naming with Referenced Content Via aria-labeledby
- If the element’s contents are not appropriate as a label, but there is an element that can be used as the label, then use the `aria-labelledby` attribute.
-
- In the following example, an element with the "switch" role is labeled by a previous sibling element.
-
- <span id="night-mode-label">Night mode</span>
- <span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span>
-
- Because a `span` element is used for the switch control, the HTML `label` element cannot be used to label it, since it only works with HTML elements that are form controls. However, the `switch` role can be used on an `input` element with `type="checkbox”`, and then HTML `label` can be used.
-
- <label for="night-mode">Night mode</label>
- <input type="checkbox" role="switch" id="night-mode">
-
- In some cases, the combination of the element’s contents and another element would be appropriate as a label. In such situations, use the `aria-labelledby` and reference both the element itself and the other element.
-
- In the following example, a "read more" link is labeled by the element itself and the article’s heading, resulting in “Read more… 7 ways you can help save the bees”.
-
- <h2 id="bees-heading">7 ways you can help save the bees</h2>
- <p>Bees are disappearing rapidly.
- Here are seven things you can do to help.</p>
- <p><a id="bees-read-more" aria-labelledby="bees-read-more bees-heading">Read more...</a></p>
-
-
-
- Label that augments the element
-
- Some roles do not get the label from the contents of the element; a label can only be set explicitly using the `aria-labelledby` or `aria-label` attributes. For elements with these roles, a label augments the element, but does not override the contents.
-
- Examples of such roles are (note that this is not a complete list):
-
-
- `alertdialog`
- `application`
- `article`
- `banner`
- `complementary`
- `navigation`
- `radiogroup`
- `search`
- `status`
-
-
- For example, the `navigation` landmark could be labeled with the purpose of the landmark. In the following snippet, a "breadcrumbs"
- navigation region is labeled explicitly using the `aria-labelledby` attribute. The HTML `nav` element has the `navigation` role by default.
-
- <nav aria-labelledby="breadcrumbs-label">
- <span id="breadcrumbs-label">You are here:</span>
- <a href="/">Home</a> >
- <a href="/books/">Books</a> >
- <a>Children's books</a>
- </nav>
+
+ The aria-labelledby property enables authors to reference other elements on the page to define an accessible name.
+ For example, the following switch is named by the text content of a previous sibling element.
+
+
+ <span id="night-mode-label">Night mode</span>
+ <span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span>
+
+
+ Note that while using aria-labelledby
is similar in this situation to using an HTML label
element with the for
attribute, one significant difference is that browsers do not automatically make clicking on the label activate the element; that is an author responsibility.
+ However, HTML label
cannot be used to label a span
element.
+ Fortunately, an HTML input
type="checkbox" allows the ARIA switch
role, so when feasible, using the following approach creates a more robust solution.
+
+
+ <label for="night-mode">Night mode</label>
+ <input type="checkbox" role="switch" id="night-mode">
+
+ The aria-labelledby
property is useful in a wide variety of situations because:
+
+ It has the highest precedence when browsers calculate accessible names, i.e., it overrides names from child content and all other naming attributes, such as aria-label
.
+ It can concatenate content from multiple elements into a single name string.
+ It incorporates content from elements regardless of their visibility, i.e., it even includes content from elements with display:none
or visibility:hidden
in the calculated name string.
+ It incorporates the value of input elements, i.e., if it references a textbox, the value of the textbox is included in the calculated name string.
+
+
+ In some cases, the most effective name for an element is its own content combined with the content of another element.
+ Because aria-labelledby
has highest precedence in name calculation, in those situations, it is possible to use aria-labelledby
to reference both the element itself and the other element.
+ In the following example, the "read more" link is named by the element itself and the article’s heading, resulting in a name of "Read more... 7 ways you can help save the bees".
+
+
+ <h2 id="bees-heading">7 ways you can help save the bees</h2>
+ <p>Bees are disappearing rapidly. Here are seven things you can do to help.</p>
+ <p><a id="bees-read-more" aria-labelledby="bees-read-more bees-heading">Read more...</a></p>
+
+
+ When multiple elements are referenced, the text content of the referenced elements will be concatenated in the order they are listed in the attribute value.
+ In addition, browsers will trim leading and trailing white space and separate the content from each element with a single space.
+
+
+ To-do: add one or two more simple but realistic examples to show reference to hidden elements and inputs, perhaps also highlighting how browsers handle spacing.
+ Short examples, 3 lines of code or less, are preferrable.
+
+
+ The aria-labelledby
property cannot be chained, i.e., if an element with aria-labelled by
references another element that also has aria-labelledby
, the aria-labelledby
attribute on the referenced element will be ignored.
+ The aria-labelledby
property cannot be applied to the descendant of an element that supports naming from content. For example, most browsers will ignore the aria-labelledby attribute in this link: <a href="/"><span aria-labelledby="elem1"></span><a>
.
+ There are certain types of elements, such as paragraphs and list items, that should not be named with aria-labelledby
. They are identified in the table in section Accessible Name Guidance by Role .
+
+ If aria-labelledby
is applied to an element with one of the roles that supports naming from child content , text content contained in the element and its descendants is hidden from assistive technology users unless it is also referenced by aria-labelledby
.
+ It is strongly recommended to avoid using this attribute to override content of one of these elements except in rare circumstances where hiding content from assistive technology users is beneficial.
+
+ Because calculating the name of an element with aria-labelledby
can be complex and reference hidden content, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
+
@@ -3953,9 +3952,9 @@ Accessible Name Guidance by Role
Todo: build a table with every concrete role with columns for:
role
- Name Required?: with values of always, sometimes, or never
+ Name Required?: with values of always, usually, sometimes, or never
Named by Content?: values of Yes or No
- Guidance: Explains sometimes and never for name required. Provides warning if named from content.
+ Guidance: Explains usually, sometimes and never for name required. Provides warning if named from content.
From 0f48fdb636ce545655e4faf026f7db6cb8f5c2f5 Mon Sep 17 00:00:00 2001
From: Matt King
Date: Sun, 12 May 2019 21:18:52 -0700
Subject: [PATCH 24/55] complete outline for naming techniques
---
aria-practices.html | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index ce20749ee1..0ddb87ba89 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3707,9 +3707,9 @@ Providing Accessible Names and Descriptions
Naming with child content.
- Naming by encapsulation with a label.
Naming with a String Attribute Via aria-label
.
Naming by Referencing Content with aria-labelledby
.
+ Naming by encapsulation with a label.
Naming with Legends and Captions.
Fallback Names Derived from Titles and Placeholders.
Describing by referencing content with aria-describedby
.
@@ -3757,7 +3757,7 @@ Accessible Names
Cardinal Rules of Naming
-
+
Rule 1: Heed Warnings and Test Thoroughly
Several of the below naming techniques include notes that warn against specific coding patterns that are either prohibitted by the ARIA specification or fall into gray space that is not yet fully specified.
@@ -3769,7 +3769,7 @@
Rule 1: Heed Warnings and Test Thoroughly
-
+
Rule 2: Prefer Visible Text
When a user interface includes visible text that could be used to provide an appropriate accessible name, using the visible text for the accessible name simplifies maintenance, prevents bugs, and reduces language translation requirements.
@@ -3777,7 +3777,7 @@
Rule 2: Prefer Visible Text
-
+
Rule 3: Prefer Native Techniques
In HTML documents, whenever possible, rely on HTML naming techniques, such as the HTML label element.
@@ -3785,7 +3785,7 @@
Rule 3: Prefer Native Techniques
-
+
Rule 4: Avoid Browser Fallback
When authors do not specify an accessible name using an element or attribute that is intended for naming, browsers attempt to help assistive technology users by resorting to fall back methods for generating a name.
@@ -3794,11 +3794,11 @@
Rule 4: Avoid Browser Fallback
-
+
Rule 5: Compose Brief, Useful Names
In the same way that visually crowded screens reduce usability, excessively long or insufficiently distinct and descriptive accessible names can make a user interface very difficult, or even impossible, to use for someone who relies on a non-visual form of the user interface.
- In other words, for a web experience to accessible, the names must be effective.
+ In other words, for a web experience to be accessible, the names must be effective.
The below section on Composing Effective and User-friendly Accessible Names provides guidance for striking an effective balance between brevity and descriptiveness.
@@ -3939,6 +3939,21 @@ Naming with Referenced Content Via aria-labeledby
Because calculating the name of an element with aria-labelledby
can be complex and reference hidden content, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
+
+
+ Naming by Encapsulation with a Label
+ Todo: write this section. Note that we could describe the ARIA label role, but state that it is not supported until ARIA 1.2 is a recommendation So, in this version, we should talk about the HTML technique first.
+
+
+
+ Naming with Legends and Captions
+ Todo: write this section. Note that we could describe the ARIA legend role, but state that it is not supported until ARIA 1.2 is a recommendation So, in this version, we should talk about the HTML technique first.
+
+
+
+ Fallback Names Derived from Titles and Placeholders
+ Todo: write this section. Needs to cover title, placeholder, and aria-placeholder.
+
From c686c11bbfe469e9eac568efa6691df6b7f7d37d Mon Sep 17 00:00:00 2001
From: Matt King
Date: Sun, 12 May 2019 23:55:44 -0700
Subject: [PATCH 25/55] Partial revision of name calculation section
---
aria-practices.html | 60 ++++++++++++++++++++++-----------------------
1 file changed, 29 insertions(+), 31 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index 0ddb87ba89..dfb2c726b3 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3952,7 +3952,10 @@ Naming with Legends and Captions
Fallback Names Derived from Titles and Placeholders
- Todo: write this section. Needs to cover title, placeholder, and aria-placeholder.
+ Todo: finish writing this section. Needs to cover title, placeholder, and aria-placeholder.
+
+ For the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
+
@@ -3975,29 +3978,34 @@ Accessible Name Guidance by Role
Accessible name calculation
- User agents follow the accessible name calculation algorithm to get the label for an element. This is defined in [https://w3c.github.io/accname/](https://w3c.github.io/accname/) and [https://w3c.github.io/html-aam/](https://w3c.github.io/html-aam/) for HTML.
- User agents attempt to formulate labels for elements by walking through a list of potential naming methods and use the first that generates a name. The algorithm is roughly like this:
+
+ User agents formulate an accessible name string for an element by walking through a list of potential naming methods and using the first that generates a name.
+ The algorithm they follow is defined in the accessible name specification .
+ It is roughly like the following:
+
+ Todo: make the steps related to HTML elements and attributes in the following list more specific so readers can see the precedence of any specific element or attribute.
- First, the `aria-labelledby` attribute is used if present.
- If the label is still empty, the `aria-label` attribute is used if present.
- If the label is still empty, then host-language-specific attributes or elements (e.g., the `alt` attribute on HTML `img`) are used if present.
- If the label is still empty, then for roles that can take label from the element's content, the element’s contents.
- Finally, if the label is still empty, then host-langauge-specific tooltip attributes or elements (e.g., the `title` attribute in HTML) are used if present.
+ The aria-labelledby
attribute is used if present.
+ If the name is still empty, the aria-label
attribute is used if present.
+ If the name is still empty, then host-language-specific attributes or elements (e.g., alt
attribute on HTML img
) are used if present.
+ If the name is still empty, then for elements with a role that supports naming from child content, the content of the element is used.
+ Finally, if the name is still empty, then other fallback host-language-specific tooltip attributes or elements (e.g., the title
attribute in HTML) are used if present.
-
- The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
-
- For example, for the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
-
-
+
+ The final step is a fallback mechanism. Generally when labelling an element, use one of the non-fallback mechanisms.
+
+
+ When calculating a name from content, the user agent walks through all descendant nodes.
+ And, when following aria-labelledby references
, it similarly walks the tree of each referenced element.
+ Thus, the naming algorithm is recursive.
+ The following two sections provide non-recursive and recursive examples of how the algorithm works.
+
+
+
Examples of non-recursive accessible name calculation
-
- For example, an img element with just a src attribute has no label (don’t do this):
-
+ Consider an img
element that has only an src
attribute and so does not have an accessible name (do not do this):
<img src="photo.jpg">
-
- If there is a `title` attribute, then that is used as the label (fallback mechanism; generally avoid doing this):
-
+ If there is a title
attribute, then it serves as a naming falback mechanism (avoid doing this):
<img src="photo.jpg" title="The Queen, holding a pigeon.">
If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
@@ -4016,9 +4024,8 @@ Examples of non-recursive accessible name calculation
<span id="the-queen">The Queen, holding a pigeon.</span>
-
+
Examples of recursive accessible name calculation
-
The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
@@ -4034,15 +4041,6 @@ Examples of recursive accessible name calculation
aria-label="Remove meeting:">X</button>
Daily status report
</div>
-
- It is also possible to reference an element using `aria-labelledby` even if that element is hidden. In the following example, the `span` element could be styled with CSS `display: none` and the `nav` element would still have the label "You are here:".
-
- <nav aria-labelledby="breadcrumbs-label">
- <span id="breadcrumbs-label">You are here:</span>
- <a href="/">Home</a> >
- <a href="/books/">Books</a> >
- <a>Children's books</a>
- </nav>
From 746b200c0e569781b7429ae1a0c53cde15efde7e Mon Sep 17 00:00:00 2001
From: JaEun Jemma Ku
Date: Thu, 16 May 2019 20:03:41 -0500
Subject: [PATCH 26/55] fix/change with feedback
---
aria-practices.html | 128 ++++++++++++++++++++++----------------------
1 file changed, 64 insertions(+), 64 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index dfb2c726b3..407720df25 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3701,7 +3701,7 @@ Examples
Providing Accessible Names and Descriptions
Providing elements with accessible names, and where appropriate, accessible descriptions is one of the most fundamental and important responsibilities authors have when developing accessible web experiences.
- While doing so is straight forward for most elements, technical mistakes that can have devistating impacts on users of assistive technologies are easy to make and unfortunately common.
+ While doing so is straight forward for most elements, technical mistakes that can have devastating impacts on users of assistive technologies are easy to make and unfortunately common.
To help authors provide effective and reliable accessible names and descriptions, this section explains their purpose, when authors need to provide them, how browsers assemble them, and rules for coding and composing them.
It then provides guidance for effectively employing the following naming and describing techniques and WAI-ARIA properties:
@@ -3730,10 +3730,10 @@ What ARE Accessible Names and Descriptions?
Both the WAI-ARIA specification and WCAG require all focusable, interactive elements to have an accessible name.
- In addition dialogs and some structural containers, such as tables and regions , are required to have a name.
+ In addition dialogs and some structural containers, such as tables and regions , are required to have a name.
Many other elements can be named, but whether a name will enhance the accessible experience is determined by various characteristics of the surrounding context.
Finally, there are some elements where providing an accessible name is technically possible but not advisable.
- The Accessible Name Guidance by Role section lists naming requirements and guidelines for every ARIA role.
+ The Accessible Name Guidance by Role section lists naming requirements and guidelines for every ARIA role.
An accessible description is also an author-provided string that is rendered by assistive technologies.
@@ -3742,7 +3742,7 @@
What ARE Accessible Names and Descriptions?
For instance, a screen reader may announce a description of an element after its name, role, value (if it is an input), and any relevant states or properties.
-
+
How Are Name and Description Strings Derived?
@@ -3751,12 +3751,12 @@
How Are Name and Description Strings Derived?
However, most authors do not need detailed understanding of the algorithms since nearly all circumstances where a name or description is useful are supported by the coding patterns described in the naming techniques and describing techniques sections.
-
+
Accessible Names
Cardinal Rules of Naming
-
+
Rule 1: Heed Warnings and Test Thoroughly
@@ -3768,23 +3768,23 @@
Rule 1: Heed Warnings and Test Thoroughly
In addition to heeding the warnings provided in the naming techniques, it is difficult to over emphasize the importance of testing to ensure that names browsers calculate match expectations.
-
+
Rule 2: Prefer Visible Text
When a user interface includes visible text that could be used to provide an appropriate accessible name, using the visible text for the accessible name simplifies maintenance, prevents bugs, and reduces language translation requirements.
- When names are generated from text that exists only in markup and is never displayed visually, there is a greater likelihood that accessible names are not updated when the user interface design or content are changed.
+ When names are generated from text that exists only in markup and is never displayed visually, there is a greater likelihood that accessible names are not updated when the user interface design or content are changed.
-
+
Rule 3: Prefer Native Techniques
In HTML documents, whenever possible, rely on HTML naming techniques, such as the HTML label element.
- While less flexible, their simplicity and reliance on visible text help ensure robust accessible experiences.
+ While less flexible, their simplicity and reliance on visible text help ensure robust accessible experiences.
-
+
Rule 4: Avoid Browser Fallback
@@ -3793,31 +3793,31 @@
Rule 4: Avoid Browser Fallback
Because the purpose of these attributes is not naming, their content typically yields low quality accessible names that are not effective.
-
+
Rule 5: Compose Brief, Useful Names
- In the same way that visually crowded screens reduce usability, excessively long or insufficiently distinct and descriptive accessible names can make a user interface very difficult, or even impossible, to use for someone who relies on a non-visual form of the user interface.
- In other words, for a web experience to be accessible, the names must be effective.
- The below section on Composing Effective and User-friendly Accessible Names provides guidance for striking an effective balance between brevity and descriptiveness.
+ In the same way that visually crowded screens reduce usability, excessively long or insufficiently distinct accessible names can make a user interface very difficult, or even impossible, to use for someone who relies on a non-visual form of the user interface.
+ In other words, for a web experience to be accessible, the names must be effective.
+ The below section on Composing Effective and User-friendly Accessible Names provides guidance for striking an effective balance between brevity and duplication.
-
+
Naming Techniques
-
+
Naming with Child Content
- There are certain elements that get their name from the content they contain.
+ Certain elements get their name from the content they contain.
For example, the following link is named "Home".
-
+
<a href="/">Home</a>
-
+
- When assistive technologies render an element, such as a link or button, that gets its accessible name from its content, the accessible name is the only content the user can perceive for that element.
+ When assistive technologies render an element, such as a link or button, that gets its accessible name from its content, the accessible name is the only content the user can perceive for that element.
This is in contrast to other elements, such as text fields or tables, where the accessible name is a label that is presented along with the value or content of the element.
For instance, the accessible name of a table can be derived from a caption element, and assistive technologies render both the caption and all other content contained inside the table.
@@ -3848,7 +3848,7 @@ Naming with Child Content
In addition, in situations where visible content is hidden from assistive technology users by use of one of these attributes, thorough testing with assistive technologies is particularly important.
-
+
Naming with a String Attribute Via aria-label
@@ -3860,7 +3860,7 @@
Naming with a String Attribute Via aria-label
The aria-label
attribute is useful when there is no visible text content that will serve as an appropriate accessible name.
- The aria-label
attribute effects assistive technology users in one of two different ways, depending on the role of the element to which it is applied.
+ The aria-label
attribute affects assistive technology users in one of two different ways, depending on the role of the element to which it is applied.
When applied to an element with one of the roles that supports naming from child content , aria-label
hides descendant content from assistive technology users and replaces the content with the value of aria-label
.
However, when applied to nearly any other type of element, assistive technologies will render both the value of aria-label and the content of the element.
For example, the name of the following navigation region is "Product".
@@ -3883,9 +3883,9 @@
Naming with a String Attribute Via aria-label
When a user interface is translated into multiple languages, ensure that aria-lable
values are translated.
-
+
- Naming with Referenced Content Via aria-labeledby
+ Naming with Referenced Content Via aria-labelledby
The aria-labelledby property enables authors to reference other elements on the page to define an accessible name.
For example, the following switch is named by the text content of a previous sibling element.
@@ -3895,9 +3895,9 @@
Naming with Referenced Content Via aria-labeledby
<span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span>
- Note that while using aria-labelledby
is similar in this situation to using an HTML label
element with the for
attribute, one significant difference is that browsers do not automatically make clicking on the label activate the element; that is an author responsibility.
+ Note that while using aria-labelledby
is similar in this situation to using an HTML label
element with the for
attribute, one significant difference is that browsers do not automatically make clicking on the labelling element activate the labelled element; that is an author responsibility.
However, HTML label
cannot be used to label a span
element.
- Fortunately, an HTML input
type="checkbox" allows the ARIA switch
role, so when feasible, using the following approach creates a more robust solution.
+ Fortunately, an HTML input
with type="checkbox"
allows the ARIA switch
role, so when feasible, using the following approach creates a more robust solution.
<label for="night-mode">Night mode</label>
@@ -3905,7 +3905,7 @@ Naming with Referenced Content Via aria-labeledby
The aria-labelledby
property is useful in a wide variety of situations because:
- It has the highest precedence when browsers calculate accessible names, i.e., it overrides names from child content and all other naming attributes, such as aria-label
.
+ It has the highest precedence when browsers calculate accessible names, i.e., it overrides names from child content and all other naming attributes, including aria-label
.
It can concatenate content from multiple elements into a single name string.
It incorporates content from elements regardless of their visibility, i.e., it even includes content from elements with display:none
or visibility:hidden
in the calculated name string.
It incorporates the value of input elements, i.e., if it references a textbox, the value of the textbox is included in the calculated name string.
@@ -3939,43 +3939,43 @@ Naming with Referenced Content Via aria-labeledby
Because calculating the name of an element with aria-labelledby
can be complex and reference hidden content, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
-
+
Naming by Encapsulation with a Label
- Todo: write this section. Note that we could describe the ARIA label role, but state that it is not supported until ARIA 1.2 is a recommendation So, in this version, we should talk about the HTML technique first.
+ To-do: write this section. Note that we could describe the ARIA label role, but state that it is not supported until ARIA 1.2 is a recommendation So, in this version, we should talk about the HTML technique first.(suggestion - specifically mention Form element, and refer back to caridinal rule 2: prefer visible text, and rule 3: prefer native techniques
-
+
Naming with Legends and Captions
- Todo: write this section. Note that we could describe the ARIA legend role, but state that it is not supported until ARIA 1.2 is a recommendation So, in this version, we should talk about the HTML technique first.
+ To-do: write this section. Note that we could describe the ARIA legend role, but state that it is not supported until ARIA 1.2 is a recommendation So, in this version, we should talk about the HTML technique first.
-
+
Fallback Names Derived from Titles and Placeholders
- Todo: finish writing this section. Needs to cover title, placeholder, and aria-placeholder.
+ To-do: finish writing this section. Needs to cover title, placeholder, and aria-placeholder.
For the HTML `input` element, the `placeholder` attribute is used as a fallback labeling mechanism if nothing else results in a label. For an `input` element, it is better to use a `label` element, since it does not disappear visually when the user focuses the form control.
-
+
Composing Effective and User-friendly Accessible Names
- Todo: Write a section that describes how to make good names, i.e., brief, descriptive, unique, front-loaded, no role names, etc.
+ To-do: Write a section that describes how to make good names, i.e., brief, descriptive, unique, front-loaded, no role names, etc.
Example practice: Do NOT include a WAI-ARIA role name in the accessible name. For example, do not include the word "button" in the name of a button or the word "navigation" in the name of a navigation region.
-
+
Accessible Name Guidance by Role
- Todo: build a table with every concrete role with columns for:
+ To-do: build a table with every concrete role with columns for:
role
Name Required?: with values of always, usually, sometimes, or never
Named by Content?: values of Yes or No
- Guidance: Explains usually, sometimes and never for name required. Provides warning if named from content.
+ Guidance: Explains usually, sometimes and never for name required. Provides warning if named from content.
-
+
Accessible name calculation
@@ -3983,7 +3983,7 @@
Accessible name calculation
The algorithm they follow is defined in the accessible name specification .
It is roughly like the following:
- Todo: make the steps related to HTML elements and attributes in the following list more specific so readers can see the precedence of any specific element or attribute.
+ To-do: make the steps related to HTML elements and attributes in the following list more specific so readers can see the precedence of any specific element or attribute.
The aria-labelledby
attribute is used if present.
If the name is still empty, the aria-label
attribute is used if present.
@@ -4000,42 +4000,42 @@ Accessible name calculation
Thus, the naming algorithm is recursive.
The following two sections provide non-recursive and recursive examples of how the algorithm works.
-
+
Examples of non-recursive accessible name calculation
Consider an img
element that has only an src
attribute and so does not have an accessible name (do not do this):
<img src="photo.jpg">
If there is a title
attribute, then it serves as a naming falback mechanism (avoid doing this):
<img src="photo.jpg" title="The Queen, holding a pigeon.">
-
+
If there is also an `alt` attribute (using `alt` for images is recommended), then that is used as the label, and the `title` attribute is instead used as the accessible description:
-
+
<img src="photo.jpg" alt="The Queen, holding a pigeon." title="Photo: Rex Features">
-
+
If there is also an `aria-label` attribute, then that overrides the `alt` attribute:
-
+
<img src="photo.jpg" aria-label="The Queen, holding a pigeon." title="Photo: Rex Features"
alt="Sorry, this image failed to load.">
-
+
If there is also an `aria-labelledby` attribute, that wins over the other attributes (the `aria-label` attribute ought to be removed if it is not used):
-
+
<img src="photo.jpg" aria-label="This is ignored." title="Photo: Established Depiction"
alt="Sorry, this image failed to load." aria-labelledby="the-queen">
<span id="the-queen">The Queen, holding a pigeon.</span>
-
+
Examples of recursive accessible name calculation
The accessible name calculation algorithm will be invoked recursively when necessary. An `aria-labelledby` reference causes the algorithm to be invoked recursively, and when computing an accessible name from content the algorithm is invoked recursively for each child node.
-
+
In this example, the label for the button is computed by recursing into each child node, resulting in "Move to trash".
-
+
<button>Move to <img src="bin.svg" alt="trash"></button>
-
+
When following an `aria-labelledby` reference, the algorithm avoids following the same reference twice in order to not end up in infinite loops.
-
+
In this example, the label for the button is computed by first following the `aria-labelledby` reference to the parent element, and then computing the label for that element from the child nodes, first visiting the `button` element again but ignoring the `aria-labelledby` reference and instead using the `aria-label` attribute, and then visiting the next child (the text node). The resulting label is "Remove meeting: Daily status report".
-
+
<div id="meeting-1">
<button aria-labelledby="meeting-1"
aria-label="Remove meeting:">X</button>
@@ -4044,23 +4044,23 @@ Examples of recursive accessible name calculation
-
+
Accessible Descriptions
Describing Techniques
-
+
Describing by referencing content with aria-describedby
The `aria-describedby` attribute works similarly to the `aria-labelledby` attribute. For example, a button could be described by a later paragraph.
-
+
<button aria-describedby="trash-desc">Move to trash</button>
...
<p id="trash-desc">Items in the trash
will be permanently removed after 30 days.</p>
-
+
This description will be presented to the user as plain text. For example, if the description contains an HTML `img` element, a text equivalent of the image is computed.
-
+
<button aria-describedby="trash-desc">
Move to <img src="bin.svg" alt="trash">
</button>
@@ -4068,11 +4068,11 @@ Describing by referencing content with aria-describedby
<p id="trash-desc">Items in <img src="bin.svg" alt="the trash">
will be permanently removed after 30 days.</p>
-
+
Describing by referencing content with aria-details
In some cases, a plain text description is insufficient. The `aria-details` attribute can be used in such situations. In this example, a text field for a passenger’s name (when booking a flight) has a description that is a list of three items, and contains a link to an external document with further details.
-
+
<ul id="full-name-desc">
<li>The passenger's name must match the name in their passport.</li>
<li>The name must consist of only characters in the A-Z range.</li>
@@ -4085,18 +4085,18 @@ Describing by referencing content with aria-details
</label></p>
...
</fieldset>
-
+
If both `aria-details` and `aria-describedby` are specified on an element, only the `aria-details` attribute is used. This can be useful in order to provide a fallback for user agents that don’t support `aria-details`.
-
+
Accessible description calculation
Like the accessible name calculation (see the earlier section), the accessible description calculation produces a plain text string for an element. This algorithm is not used for the `aria-details` attribute.
The accessible description calculation algorithm is the same algorithm as the accessible name calculation algorithm, but it branches off in some places depending on whether a name or a description is being calculated. In particular, when collecting an accessible description, the algorithm uses `aria-describedby` instead of `aria-labelledby`.
As with `aria-labelledby`, it is possible to reference an element using `aria-describedby` even if that element is hidden.
For example, a text field in a form could have a description that is hidden by default, but can be revealed on request using a disclosure widget. The description could also be referenced from the text field directly with `aria-describedby`. The accessible description for the `input` element is "Your username is the name that you use to log in to this service.".
-
+
<label for="username">Username</label>
<input id="username" name="username" aria-describedby="username-desc">
<button aria-expanded="false" aria-controls="username-desc" aria-label="Help about username">?</button>
From 490eaed602ee093996df11ba1156a18803e12493 Mon Sep 17 00:00:00 2001
From: JaEun Jemma Ku
Date: Thu, 16 May 2019 20:51:38 -0500
Subject: [PATCH 27/55] lint testing and one typo fix
---
aria-practices.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/aria-practices.html b/aria-practices.html
index 407720df25..a72cce742f 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3707,7 +3707,7 @@ Providing Accessible Names and Descriptions
Naming with child content.
- Naming with a String Attribute Via aria-label
.
+ Naming with a String Attribute Via aria-lable
.
Naming by Referencing Content with aria-labelledby
.
Naming by encapsulation with a label.
Naming with Legends and Captions.
From 0536ec86dc5e70277b921290022ce9a9b93190d5 Mon Sep 17 00:00:00 2001
From: JaEun Jemma Ku
Date: Thu, 16 May 2019 20:56:23 -0500
Subject: [PATCH 28/55] fix typo
---
aria-practices.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/aria-practices.html b/aria-practices.html
index a72cce742f..c625fad548 100644
--- a/aria-practices.html
+++ b/aria-practices.html
@@ -3707,7 +3707,7 @@ Providing Accessible Names and Descriptions
Naming with child content.
- Naming with a String Attribute Via aria-lable
.
+ Naming with a String Attribute Via aria-label
.
Naming by Referencing Content with aria-labelledby
.
Naming by encapsulation with a label.
Naming with Legends and Captions.
@@ -3880,7 +3880,7 @@ Naming with a String Attribute Via aria-label
There are certain types of elements, such as paragraphs and list items, that should not be named with aria-label
. They are identified in the table in section Accessible Name Guidance by Role .
Because the value of aria-label
is not rendered visually, testing with assistive technologies to ensure the expected name is presented to users is particularly important.
- When a user interface is translated into multiple languages, ensure that aria-lable
values are translated.
+ When a user interface is translated into multiple languages, ensure that aria-label
values are translated.
From 4b3c7b3927add742b9ca43f008801b9eb2e3a175 Mon Sep 17 00:00:00 2001
From: JaEun Jemma Ku
Date: Thu, 16 May 2019 22:10:55 -0500
Subject: [PATCH 29/55] set up meter example
---
examples/meter/meter.html | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 examples/meter/meter.html
diff --git a/examples/meter/meter.html b/examples/meter/meter.html
new file mode 100644
index 0000000000..e69de29bb2
From fc34fc3a452ad6439dafc3777ec21a6c2db35f84 Mon Sep 17 00:00:00 2001
From: JaEun Jemma Ku
Date: Thu, 16 May 2019 22:17:49 -0500
Subject: [PATCH 30/55] copy of google meter example
---
examples/meter/meter.html | 68 +++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/examples/meter/meter.html b/examples/meter/meter.html
index e69de29bb2..b731a04f68 100644
--- a/examples/meter/meter.html
+++ b/examples/meter/meter.html
@@ -0,0 +1,68 @@
+
+
+
+ Meter Blueprint
+
+
+
+
+ This meter changes its value randomly every 5 seconds.
+
+
+
From 4016485df5fdf0b0a9833f41074ce0c82b1c8d05 Mon Sep 17 00:00:00 2001
From: JaEun Jemma Ku
Date: Thu, 16 May 2019 22:24:26 -0500
Subject: [PATCH 31/55] recover the memory of APG example set up
---
examples/meter/css/meter.css | 13 +++++++++++++
examples/meter/meter.html | 16 ++--------------
2 files changed, 15 insertions(+), 14 deletions(-)
create mode 100644 examples/meter/css/meter.css
diff --git a/examples/meter/css/meter.css b/examples/meter/css/meter.css
new file mode 100644
index 0000000000..18a5519086
--- /dev/null
+++ b/examples/meter/css/meter.css
@@ -0,0 +1,13 @@
+
+[role=meter] {
+ position: relative;
+ border: 4px solid black;
+ height: 20px;
+ width: 200px;
+}
+
+#fill {
+ position: absolute;
+ height: 100%;
+ background-color: black;
+}
diff --git a/examples/meter/meter.html b/examples/meter/meter.html
index b731a04f68..a34642b33b 100644
--- a/examples/meter/meter.html
+++ b/examples/meter/meter.html
@@ -2,20 +2,8 @@
Meter Blueprint
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Meter Example
+ The following meter examples demonstrate the meter design pattern .
+
+
+ Example
+
+
+
+
+
This meter changes its value randomly every 5 seconds.
+
+
+
+
+
+ Keyboard Support
+
+
+
+
+ Key
+ Function
+
+
+
+
+ Home
+ Sets meter to its minimum value?
+
+
+
+ End
+ Sets meter to its maximum value?
+
+
+
+
+
+
+ Role, Property, State, and Tabindex Attributes
+
+
+
+ Role
+ Attribute
+ Element
+ Usage
+
+
+
+
+ meter
+
+
+ div
+
+
+
+ Identifies the element as a meter
widget.
+
+
+
+
+
+
+ tabindex="0"
+
+
+ div
+
+
+
+ Includes the element in the tab sequence.
+
+
+
+
+
+ aria-valuemin="NUMBER"
+ div
+
+
+ Specifies a numeric value that is the minimum value the meter can have.
+
+
+
+
+
+ aria-valuemax="NUMBER"
+ div
+
+
+ Specifies a numeric value that is the maximum value the meter can have.
+
+
+
+
+
+ aria-valuenow="NUMBER"
+ div
+
+
+ A numeric value that is the current value of the meter
+
+
+
+
+
+ aria-label
+ div
+
+
+ Identifies the accessible name for meter
widget.
+
+
+
+
+ presentation
+
+
+ div
+
+
+
+ Identifies that the visual indicator of meter value is being used only for visual presentation.
+
+
+
+
+
+
+
+
+
+ Javascript and CSS Source Code
+
+
+
+
+
+ HTML Source Code
+
+
+
+
+
+
+
-
-
- This meter changes its value randomly every 5 seconds.
-
-
+
+
+
+
+ Meter Design Pattern in WAI-ARIA Authoring Practices 1.1
+
+