-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guideline for labeling and describing #994
Changes from 1 commit
de49b61
713aa1f
ae9a5ed
ce15b81
f0ddc15
3e08581
801539f
61f20ae
8792871
c3ec1e9
6b45492
5727205
07cd850
78e912c
a8651d1
7773aae
54e551b
1bf0f40
16008f5
0f0524f
e131ba5
a40f81b
93c9ec7
9276759
0f48fdb
c686c11
6574f8a
746b200
490eaed
0536ec8
b4a87d8
b596c68
edf4be5
7eb5d5d
bdb67d6
fb4f995
82a8e82
702837a
6c64491
0612ba8
1fd6368
b2e2067
c229c76
8e8ec74
6451e91
ab90611
e2138b9
66f945b
aa068f6
5046495
b977ba5
cccb053
87179dc
1743094
3a005b1
7fb3244
32c5ca0
7806b3e
b530fea
16964ba
9fd5cb4
892ccff
9f8aab4
9604f46
5717568
06cc073
03efdcc
ae90ce1
2cfd46e
df4bab3
ac301c6
a1bd62f
1e56e16
26a4b1c
5602d9f
7e9e68c
66a46fc
1097ac6
47f75ca
063a631
261a261
3e406d2
b87ad08
3d1f8d3
cd01400
73df64e
dab3706
6bf004f
014d0d8
1a25bf3
6b0984b
0a87de0
5e39a2f
37e7136
66095e4
50c9880
7443aa1
4d990cc
c59cc43
774b26c
8a832bd
7f17265
8fb9dbe
a16cf6b
972fe21
47887c0
8de8e44
1d38d3b
debb672
82f3b2f
1ee6b09
0797c1e
03f1ee2
be8ed01
bed7986
ae5938c
f1b5a93
0e10d37
50fc11d
ffc6261
788130a
ef3d1f9
a0f4104
a735dc8
ef6c098
9ffece9
ab3f3cc
9704274
2badb95
875a294
dee5cec
45f39da
f55702a
1db2ced
826e12b
299cab5
af5793c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider wording without "should" ... Only override the content if ... or something like that. Describing what is appropriate or adequate as a label is out of scope, but if we are going to use the word, "appropriate", we should probably link to a w3c resource where that is covered. That might be part of the introductory paragraph. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. Is there something appropriate (ahem) we can link to? |
||
|
||
In the following example, a link (with default role "link") gets its label from the element’s contents. | ||
|
||
``` | ||
<a href="/">Home</a> | ||
``` | ||
|
||
|
||
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. | ||
|
||
``` | ||
<span id="night-mode-label">Night mode</span> | ||
<span role="switch" aria-checked="false" tabindex="0" aria-labelledby="night-mode-label"></span> | ||
``` | ||
|
||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Beautiful! Very complex concept made super simple! |
||
|
||
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”. | ||
|
||
``` | ||
<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> | ||
``` | ||
zcorpan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
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. | ||
|
||
``` | ||
<button type="button" aria-label="Close">X</button> | ||
``` | ||
|
||
|
||
### 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may not want to assume the term accessible name is meaningful to readers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Filed #996