Skip to content

Image non empty acc name - revised PR #1382

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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

dd8
Copy link
Collaborator

@dd8 dd8 commented Jul 8, 2020

The PR replaces #1208

Reason for new PR: rule has been renamed, and many changes from original PR were merged in #1300

This PR:

  • restricts the applicability to elements that render an image (to make <img/> and <div style='background-image:none'> inapplicable because they have no visual rendering, and are not voiced)
  • adds <img/> as an inapplicable example
  • adds additional failed examples like <img srcset='...'/>

Closes issue(s):

Need for Final Call:
This will require a 2 week Final Call


Pull Request Etiquette

When creating PR:

  • Make sure you're requesting to pull a branch (right side) to the develop branch (left side).

After creating PR:

  • Add yourself (and co-authors) as "Assignees" for PR.
  • Add label to indicate if it's a Rule, Definition or Chore.
  • Link the PR to any issue it solves. This will be done automatically by referencing the issue at the top of this comment in the indicated place.
  • Optionally request feedback from anyone in particular by assigning them as "Reviewers".

When merging a PR:

  • Close any issue that the PR resolves. This will happen automatically upon merging if the PR was correctly linked to the issue, e.g. by referencing the issue at the top of this comment.

How to Review And Approve

  • Go to the “Files changed” tab
  • Here you will have the option to leave comments on different lines.
  • Once the review is completed, find the “Review changes” button in the top right, select “Approve” (if you are really confident in the rule) or "Request changes" and click “Submit review”.
  • Make sure to also review the proposed Final Call period. In case of disagreement, the longer period wins.

@dd8
Copy link
Collaborator Author

dd8 commented Jul 8, 2020

I don't have repo rights to do these:

  • Add yourself (and co-authors) as "Assignees" for PR.
  • Add label to indicate if it's a Rule, Definition or Chore.
  • Optionally request feedback from anyone in particular by assigning them as "Reviewers".

Can someone with repo maintainer rights do them? Thanks.

@carlosapaduarte carlosapaduarte added reviewers wanted Rule Update Use this label for an existing rule that is being updated labels Jul 8, 2020
Copy link
Member

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Just a small editorial suggestion.

Jym77
Jym77 previously requested changes Jul 9, 2020
Copy link
Collaborator

@Jym77 Jym77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. Some minor comments.

@dd8
Copy link
Collaborator Author

dd8 commented Jul 12, 2020

I think that's all the requested changes addressed. I think it's important to reference the HTML represents nothing definition somewhere in the rule, but I'm not convinced doing it from the examples is the right place.

@Jym77 Jym77 dismissed their stale review March 1, 2022 10:16

Changes have been done

@Jym77 Jym77 self-requested a review March 1, 2022 10:16
@Jym77 Jym77 dismissed WilcoFiers’s stale review March 1, 2022 10:17

Changes have been done

@Jym77 Jym77 requested a review from WilcoFiers March 1, 2022 10:17
This `img` element has no `src` attribute and no `alt` attribute so does not render an image and [represents nothing][].

```html
<img />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this with fresh eyes. I don't think this is correct. These actually should fail SC 1.1.1. Here's my reasoning:

  1. These img elements are content, because they are nodes in the accessibility tree
  2. There is no text here, so if 1 is true, these quality as non-text content
  3. Since these are invisible, the "Decoration, Formatting, Invisible" applies
  4. Since these aren't marked up with aria-hidden=true,role=none or alt="", assistive technologies will not consistently ignore them
  5. Because these are not ignored by assistive technologies, the exception isn't met, and so 1.1.1 is not satisfied

I think I'd prefer to keep this rule as is to be honest. That ARIA in HTML explicitly says that an img with no alt attribute has a semantic role of img suggests to me this proposal not how the W3C expects this to be interpreted, even if some AT will ignore some of these (depending on the verbosity setting). It might be better just to mention this in the accessibility support section.

Copy link
Collaborator Author

@dd8 dd8 Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the <img/> example (an image with no src and no alt). This isn't rendered on screen in Chrome/FF/Safari. It cannot render non-text content since it has no src.

It is exposed as role=img in Chrome/Firefox. The image does not appear in the accessibility tree in Safari.

There are two contradictory specs:

  • html-map maps all img elements without alt to role=img (even if they have no src)
  • the HTML spec says an img with no alt and no src represents nothing (i.e. has no semantics)

The html-aam mapping is here:
https://www.w3.org/TR/html-aam-1.0/#el-img

The HTML spec says:

If the src attribute is not set and either the alt attribute is set to the empty string or the alt attribute is not set at all
The element represents nothing.

https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element

The HTML spec defines "represents nothing" as meaning the element has no semantics.

Note sure what do do here:

  • you can make the argument <img/> should not fail 1.1.1 since there's no non-text content
  • you can also make the argument <img/> should fail 1.1.1 since it's exposed as an role=img by html-aam

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should raise the issue to the HTML AAM 🤔
To see if img with no source should still have an image role or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue filed at w3c/html-aam#439

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per w3c/aria#2221 closing that issue, ARIA is moving toward giving these img elements with no/empty src an implicit role of none.

@WilcoFiers Does that solve your concerns about this PR?

@Jym77 Jym77 dismissed WilcoFiers’s stale review February 7, 2025 15:20

Comment answered

@Jym77 Jym77 requested a review from WilcoFiers February 7, 2025 15:20
@HelenBurge HelenBurge requested a review from zlayaAvocado May 29, 2025 14:14
@HelenBurge HelenBurge requested a review from shunguoy May 29, 2025 14:14
@@ -146,6 +151,33 @@ This `img` element inside a `div` positioned off screen has an [implicit role][]
</div>
```

#### Passed Example 9

This `img` element displays a CSS `background-image` and has an [accessible name][] because of the `alt` attribute.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need a separate example with a background: url(./w3c.png)? Or does this assume that the computed css value if we set a background will be background-image?

@@ -228,10 +287,38 @@ This element is neither an `img` element nor has a role of `img`.
<div aria-label="W3C logo"></div>
```

#### Inapplicable Example 5

This `img` element has no `src` attribute and no `alt` attribute so does not render an image and [represents nothing][].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This `img` element has no `src` attribute and no `alt` attribute so does not render an image and [represents nothing][].
This `img` element has no `src` attribute and no `alt` attribute or accessible name so does not render an image and [represents nothing][].

just clarifying it from https://github.com/w3c/aria/pull/2221/files#diff-5c3c8936e81538898c83ae11f5271e9ae9324925713a3b03aca58cbd2a3c3014R3133

Comment on lines +306 to +313
#### Inapplicable Example 7

This `img` element has an `src` attribute which will cause the [image request state][] to be [Broken](https://html.spec.whatwg.org/#img-error).

```html
<img src="/test-assets/does-not-exist.png" />
```

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WilcoFiers can you weight on this? It doesn't seem like it's in the exception of WCAG 1.1.1 and I am not sure if it's inapplicable.

  1. It will still render and will be mapped to the image role since src is not empty
  2. Some screenreaders might announce a file name instead if there is a src attribute (even if it's not loading) but no alt provided, which would not be the text alternative for the image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting problem. After re-reading WCAG definitions a couple times I think that yes, this fails 1.1.1. I think this element falls under non-text content. Content isn't defined in WCAG, but I'd say since this is both in the accessibility tree, and visible to people, I can't see a reason to say this wouldn't be content. It's non-text content because everything that isn't text content is non-text content.

SC 1.1.1 applies to all non-text content, we can debate whether this is decorative or not. But in either case not having an alt does fail WCAG. So I agree with you, this should not be inapplicable.

HTML elements render an image if any of the following are true:

- The element is an `img` element where the [current request][]'s [state][image request state] is [completely available][].
- The element has a CSS `background-image` that does not [draw nothing](https://www.w3.org/TR/css-backgrounds-3/#the-background-image).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the "draws nothing" description it's mentioned about the background size: "An image that is empty (zero width or zero height) likewise counts as a layer but draws nothing"

Would the following example be also non applicable then, or only the image with the original size of 0 width and height?

   <img
      style="
        width: 72px;
        height: 48px;
        background-image: url('./w3c.png'); // image size is 50px by 50px
        background-size: 0; // change background size to 0
      "
    />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rule Update Use this label for an existing rule that is being updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants