-
Notifications
You must be signed in to change notification settings - Fork 71
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
Amendments to button and image button rules #1184
Conversation
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 job!
I think the first rule ("non empty accessible name") is now a bit "heavy" with the image button examples. The point is to not single them out so we maybe don't need to insist that image button are buttons (input with a type in the Button/Reset Button/Submit Button states are also buttons but we don't have any examples of these, typically)
**Note:** `input` elements have a `type` attribute in the `Image button` state if it is set to any case-insensitive match of `image` (most of the time, using `<input type="image">`). | ||
|
||
**Note:** The specification of the [`type`](https://html.spec.whatwg.org/#states-of-the-type-attribute) attribute describes in detail how to map the value of the attribute to its corresponding state. | ||
|
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.
I think both these notes can now go away.
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.
Are either of these notes required later in regard a specific example. Required for understanding, as opposed to nice-to-have.
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.
If they are only required for understanding an example or two, they should probably be moved to the description of these examples. With the new applicability which has nothing to do with type
or Image button
, they look completely out of the place and it is not clear why a rule about buttons need this (for example, why precising how to put an input
in the Image button
state, but not precise how to put it in the Button
, Reset Button
or Submit Button
state? And why even mention input
elements on a rule about buttons?)
#### Failed Example 5 | ||
|
||
This `input` element with 'type' attribute in the `Image button` state has an empty [accessible name][]. The `name` attribute can not be used to provide an [accessible name][]. | ||
|
||
```html | ||
<input type="image" name="search" src="/test-assets/shared/search-icon.svg" /> | ||
``` | ||
|
||
#### Failed Example 6 | ||
|
||
This image button has an empty `alt` attribute, and no other attributes that can give it an [accessible name][]. | ||
|
||
```html | ||
<input type="image" src="/test-assets/shared/search-icon.svg" alt="" /> | ||
``` | ||
|
||
#### Failed Example 7 | ||
|
||
This image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][]. | ||
|
||
```html | ||
<input type="image" src="/test-assets/shared/search-icon.svg" aria-labelledby="non-existing" /> | ||
``` | ||
|
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.
These examples might be hitting the corner case of the HTML AAM overloading the accessible name computation:
https://www.w3.org/TR/html-aam-1.0/#input-type-image (step 4)
Can you try and run some tests on major browsers to check what they do?
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.
This example in Chrome and Safari, defaults to a submit button programmatically. If the image doesn't load, the word 'Submit' will become the button text.
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.
So, the description of "empty accessible name" is not correct. And these examples do not actually fail this rule (they fail the other rule given that the name is not descriptive).
The `button` element is tested separately from the `img` element. [Success Criterion 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG21/#name-role-value) is applied to the button, whereas the image is tested under [Success Criterion 1.1.1 Non-text Content](https://www.w3.org/TR/WCAG21/#non-text-content) | ||
|
||
```html | ||
<button><img src="/test-assets/shared/search-icon.svg" alt="Search" /></button> |
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.
The button
element still has a semantic role of button
and thus is applicable for the rule.
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.
Would this code ever be considered an image button? Or is it a failed example?
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.
This is not an image button as per the sense "input
element in the Image Button
state".
But this is the rule checking that elements with role of button
have a (non empty) accessible name. In that case, there is an element with a role of button
(the button
element itself), thus the rule is applicable and passes because the button
element gets its name from the content, here the, alt
attribute of the image (iirc).
#### Failed Example 1 | ||
|
||
The image button element has an empty [accessible name][]. The `name` attribute can not be used to provide an [accessible name][]. | ||
This `input` element with 'type' attribute in the `Image button` state has an empty [accessible name][], which cannot be descriptive. The `name` attribute does not provide an [accessible name][]. | ||
|
||
```html | ||
<input type="image" name="search" src="/test-assets/shared/search-icon.svg" /> | ||
``` | ||
|
||
#### Failed Example 2 | ||
|
||
The image button has an empty `alt` attribute, and no other attributes that can give it an [accessible name][]. | ||
This image button has an `alt` attribute that is not descriptive as the [accessible name][]. | ||
|
||
```html | ||
<input type="image" src="/test-assets/shared/search-icon.svg" alt="" /> | ||
<input type="image" src="/test-assets/shared/search-icon.svg" alt="Share" /> | ||
``` | ||
|
||
#### Failed Example 3 | ||
|
||
The image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][]. | ||
The image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][], which cannot be descriptive. |
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.
As with the other rule. These may actually have an accessible name according to the AAM.
OTOH, this is probably easier to get failed examples here given that the default name is "Submit Query"…
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.
I guess in this instance the default would not be descriptive.
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.
Yes, but the description should say so rather than saying that it has an empty accessible name.
This `button` element is separate from the `img` element. | ||
|
||
```html | ||
<button><img src="/test-assets/shared/search-icon.svg" alt="Search" /></button> | ||
``` | ||
|
||
#### Inapplicable Example 4 | ||
|
||
The `img` element is not a user interface component, and so is not tested for [Success Criterion 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG21/#name-role-value). | ||
This `img` element is not button component. |
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.
Description of these two examples could also be in the line of "There is no input element in the Image button state" (to match applicability more closely). Likely adding the extra explanation as second sentence.
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.
Could you provide some suggestions so I can better understand what you mean. Thanks.
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.
The rule is applicable to input
elements in the Image Button
state. So the reason that these snippets are inapplicable is the lack of such elements. It has nothing to do with button
elements or components. To match the example description syntax, both these should be
"There is no input
element in the Image Button
state."
An extra sentence can be added. Maybe for Inapplicable Example 3 "A button
element containing only an img
element is not an Image Button, this rule specifically checks for input
elements in the Image Button
state". And for Inapplicable Example 4 "The img
element alone is not an Image Button."
Co-Authored-By: Jean-Yves Moyen <jym@siteimprove.com>
This image button has an [accessible name][] through the `aria-label` attribute. | ||
|
||
```html | ||
<input type="image" src="/test-assets/shared/search-icon.svg" aria-label="Search" /> |
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.
Not sure this adds anything not already covered in Passed Example 3
|
||
```html | ||
<input type="image" src="/test-assets/shared/search-icon.svg" title="Search" /> | ||
``` |
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.
Is a title attribute considered accessible in this situation?
Co-Authored-By: Jean-Yves Moyen <jym@siteimprove.com>
**Note:** `input` elements have a `type` attribute in the `Image button` state if it is set to any case-insensitive match of `image` (most of the time, using `<input type="image">`). | ||
|
||
**Note:** The specification of the [`type`](https://html.spec.whatwg.org/#states-of-the-type-attribute) attribute describes in detail how to map the value of the attribute to its corresponding state. | ||
|
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.
If they are only required for understanding an example or two, they should probably be moved to the description of these examples. With the new applicability which has nothing to do with type
or Image button
, they look completely out of the place and it is not clear why a rule about buttons need this (for example, why precising how to put an input
in the Image button
state, but not precise how to put it in the Button
, Reset Button
or Submit Button
state? And why even mention input
elements on a rule about buttons?)
#### Failed Example 5 | ||
|
||
This `input` element with 'type' attribute in the `Image button` state has an empty [accessible name][]. The `name` attribute can not be used to provide an [accessible name][]. | ||
|
||
```html | ||
<input type="image" name="search" src="/test-assets/shared/search-icon.svg" /> | ||
``` | ||
|
||
#### Failed Example 6 | ||
|
||
This image button has an empty `alt` attribute, and no other attributes that can give it an [accessible name][]. | ||
|
||
```html | ||
<input type="image" src="/test-assets/shared/search-icon.svg" alt="" /> | ||
``` | ||
|
||
#### Failed Example 7 | ||
|
||
This image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][]. | ||
|
||
```html | ||
<input type="image" src="/test-assets/shared/search-icon.svg" aria-labelledby="non-existing" /> | ||
``` | ||
|
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.
So, the description of "empty accessible name" is not correct. And these examples do not actually fail this rule (they fail the other rule given that the name is not descriptive).
The `button` element is tested separately from the `img` element. [Success Criterion 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG21/#name-role-value) is applied to the button, whereas the image is tested under [Success Criterion 1.1.1 Non-text Content](https://www.w3.org/TR/WCAG21/#non-text-content) | ||
|
||
```html | ||
<button><img src="/test-assets/shared/search-icon.svg" alt="Search" /></button> |
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.
This is not an image button as per the sense "input
element in the Image Button
state".
But this is the rule checking that elements with role of button
have a (non empty) accessible name. In that case, there is an element with a role of button
(the button
element itself), thus the rule is applicable and passes because the button
element gets its name from the content, here the, alt
attribute of the image (iirc).
#### Failed Example 1 | ||
|
||
The image button element has an empty [accessible name][]. The `name` attribute can not be used to provide an [accessible name][]. | ||
This `input` element with 'type' attribute in the `Image button` state has an empty [accessible name][], which cannot be descriptive. The `name` attribute does not provide an [accessible name][]. | ||
|
||
```html | ||
<input type="image" name="search" src="/test-assets/shared/search-icon.svg" /> | ||
``` | ||
|
||
#### Failed Example 2 | ||
|
||
The image button has an empty `alt` attribute, and no other attributes that can give it an [accessible name][]. | ||
This image button has an `alt` attribute that is not descriptive as the [accessible name][]. | ||
|
||
```html | ||
<input type="image" src="/test-assets/shared/search-icon.svg" alt="" /> | ||
<input type="image" src="/test-assets/shared/search-icon.svg" alt="Share" /> | ||
``` | ||
|
||
#### Failed Example 3 | ||
|
||
The image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][]. | ||
The image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][], which cannot be descriptive. |
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.
Yes, but the description should say so rather than saying that it has an empty accessible name.
This `button` element is separate from the `img` element. | ||
|
||
```html | ||
<button><img src="/test-assets/shared/search-icon.svg" alt="Search" /></button> | ||
``` | ||
|
||
#### Inapplicable Example 4 | ||
|
||
The `img` element is not a user interface component, and so is not tested for [Success Criterion 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG21/#name-role-value). | ||
This `img` element is not button component. |
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.
The rule is applicable to input
elements in the Image Button
state. So the reason that these snippets are inapplicable is the lack of such elements. It has nothing to do with button
elements or components. To match the example description syntax, both these should be
"There is no input
element in the Image Button
state."
An extra sentence can be added. Maybe for Inapplicable Example 3 "A button
element containing only an img
element is not an Image Button, this rule specifically checks for input
elements in the Image Button
state". And for Inapplicable Example 4 "The img
element alone is not an Image Button."
Note - check if this has impact on image button has accessible name, which is a rule that has already been accepted by the task force and changes may need to be resubmitted. See #1120 |
Closing due to inactivity. |
Following decisions in conversation raised by #1049, this PR combines rules regarding buttons and image buttons having an accessible name, and creates a new rule about whether the accessible name of an image button describes its purpose.
When reviewing, please also point out any out of dates formats or phrasing. I have tried to adjust those as I've worked.
Issue(s):
Need for Final Call:
This will require a 2 week Final Call, as it includes a new rule.
Pull Request Etiquette
When creating PR:
develop
branch (left side).After creating PR:
Rule
,Definition
orChore
.How to Review And Approve