Skip to content
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

Consider ignoring pseudo element content for accname if it has explicitly empty alt text #194

Closed
sivakusayan opened this issue Jun 6, 2023 · 10 comments
Assignees

Comments

@sivakusayan
Copy link

sivakusayan commented Jun 6, 2023

In step 2F.ii, it says that browsers should:

Check for CSS generated textual content associated with the current node and include it in the accumulated text. The CSS :before and :after pseudo elements [CSS2] can provide textual content for elements that have a content model.

  • For :before pseudo elements, User agents MUST prepend CSS textual content, without a space, to the textual content of the current node.
  • For :after pseudo elements, User agents MUST append CSS textual content, without a space, to the textual content of the current node.

However, we also have the option of setting alt text for the CSS content. Maybe I'm misunderstanding something, but I think it would be nice if CSS content with empty alt text was ignored altogether when computing the accessible name.

@scottaohara
Copy link
Member

this is interesting...

i had never even thought to try adding content alt text to a content string that wasn't either a url or a unicode character.

but if one were to do:

div::after {
 content: "visible text"  / "alt text";
}

then "alt text" would become the exposed content in the a11y tree, while "visible text" would remain rendered on the page. that seems, odd and prone to abuse.

@sivakusayan
Copy link
Author

Yeah 🙁 I guess I could also see people doing things like:

div::after {
 content: ""  / "screen reader only text";
}

I still think it could potentially be useful to mark certain characters as presentational. For example, if someone wanted to add a hashtag next to headings in a blog (as an additional visual cue for heading permalinks) they could do something like:

<h2 id="some-heading">
  <a href="#some-heading">
    Some heading
  </a>
</h2>

then in the CSS:

h2::before {
  content: "#" / "";
}

Would it make sense to only respect the alt text if the alt text is explicitly empty? That would make it so pseudo element content inclusion is similar to what's done in step 2A where hidden nodes are ignored.

@jnurthen jnurthen added the Agenda label Jun 8, 2023
@cookiecrook
Copy link
Contributor

cookiecrook commented Jun 8, 2023

I put in some WPT placeholders for these tests in:
web-platform-tests/interop-accessibility#36

and I'm very familiar with the decade of history of alternative text for CSS generated content with -webkit-alt:, alt:, and later this newer syntax adopted by Elika to better support the cascade. Looking forward to discussing.

@spectranaut
Copy link
Contributor

@cyns volunteered to write tests! :) cyns when you assign yourself to the test issue you can unassign yourself here

@cookiecrook
Copy link
Contributor

I agree that

content: "foo" / "";

Is effectively equivalent to alt="" and "foo" should therefore be ignored in the accname comp.

But I want to make sure we're not suggesting emptying the pseudo-element alternative when the optional alt fallback is not specified, like this:

content: "foo";

the pseudo element's label here should remain "foo" not "".

@cookiecrook
Copy link
Contributor

@cyns volunteered to write tests! :) cyns when you assign yourself to the test issue you can unassign yourself here

Here's the issue, but I don't think @cyns is assignable... Did you check your team invitation?
web-platform-tests/interop-accessibility#36

@sivakusayan
Copy link
Author

sivakusayan commented Jun 28, 2023

@cookiecrook

But I want to make sure we're not suggesting emptying the pseudo-element alternative when the optional alt fallback is not specified.

Yeah, that was what I meant to say. I'll change the title to mention "explicitly empty alt text" rather than just "empty alt text" to make it more clear.

@sivakusayan sivakusayan changed the title Consider ignoring pseudo element content for accname if it has empty alt text Consider ignoring pseudo element content for accname if it has explicitly empty alt text Jun 28, 2023
@spectranaut
Copy link
Contributor

@cookiecrook this still has f2fcandidate on it, is there more on this to discuss at TPAC in sept?

@cookiecrook
Copy link
Contributor

Sorry I forgot about this one, but I have started writing the tests in:

I'd suggest this issue is overcome by the first one of these new issues?

@sivakusayan
Copy link
Author

I agree, let's close this in favor of the more general issue 🙂

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants