#351: Alternative Text for CSS Generated Content
Discussions
Comment by @Jxck Mar 23, 2019 (See Github)
Hi
seems basic question but I think css is for style.
if you need to add alt text (for AT or so) to that image, it's a content not for style.
then you can of course use <img>
instead.
is there any reason don't let them use img if you think its necessary to add alt text for AT or so ?
Comment by @dot-miniscule Mar 28, 2019 (See Github)
True, but authors can and do use css generated content to supply semantic information which should have an alt text to make it available to AT.
On Sat, Mar 23, 2019 at 2:06 AM Jxck notifications@github.com wrote:
Hi
seems basic question but I think css is for style. if you need to add alt text (for AT or so) to that image, it's a content not for style. then you can of course use <img> instead. is there any reason don't let them use img if you think its necessary to add alt text for AT or so ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/w3ctag/design-reviews/issues/351#issuecomment-475853646, or mute the thread https://github.com/notifications/unsubscribe-auth/AikYipPWP_tWjabYZ2MyGK2PVEwyhioyks5vZe6GgaJpZM4bprE9 .
Comment by @annevk Mar 28, 2019 (See Github)
This is an interesting tipping point. There's been all this advocacy that CSS is supposed to be optional and HTML should be readable without it, but this would go right against that.
Do we have reason to believe that developers abusing CSS for adding content would use this feature? That is, if they are not informed about CSS being optional, why would they be informed about this?
Comment by @alice Mar 28, 2019 (See Github)
@annevk What do you mean, abusing CSS for adding content? Could you point to an example?
The explainer had a couple of examples of how we expect this feature to be used.
Comment by @annevk Mar 28, 2019 (See Github)
E.g., dl.domintro::before { content: 'For web developers (non-normative)'; }
from https://resources.whatwg.org/spec.css is misuse of CSS I'd say, going from the assumption that CSS is optional or could have been completely overridden by the user.
Comment by @alice Mar 28, 2019 (See Github)
@robdodson had some good responses from developers on when they'd want to use this feature, from his tweet here: https://twitter.com/rob_dodson/status/1090060058224803840
Your objection seems to be more about :content
in general, which as @dot-miniscule pointed out is already used in this way. This feature doesn't change that; it just gives authors a way to change its expression in the accessibility tree, just as they can for any other DOM content. I'd really prefer not to re-litigate :content
in this thread.
Comment by @alice Mar 29, 2019 (See Github)
Had a chat offline with @annevk and he clarified that it was less an objection and more of a philosophical query, which led to https://github.com/w3c/csswg-drafts/issues/3778
In terms of this specific case, the cat is really out of the bag in terms of :content
being exposed in the accessibility tree, and the responses to Rob's tweet shows that authors are looking for a way to fine-tune that content.
Comment by @Jxck Mar 30, 2019 (See Github)
I think so about cat is out of the bag really.
but this spec justifies the means of contents
is really a contents not only for style.
for example, if TA cares Content in HTML, ignores Style (its not wired for me), contents author can recognize it's bad for adding Content in CSS content
and we also enlighte them to sparate Style and Content.
but once this spec will standardized, put Contents in Style is justified by annotating with alt.
it's end up with TA author MUST parse all css if they wanna assist accessing user to Content.
and User can't disable CSS (like Reader Mode in these days) because of CSS has not only Style but also Content too. (I don't talk about Reader Mode implementation detail).
but If you says "That is Current Web and support that by Standard Spec", I can say nothing :(
Comment by @alice Mar 30, 2019 (See Github)
The accessibility tree already depends on CSS, and has done for a long while; for example, display: none
will cause an Element to be excluded from the accessibility tree (because it's not rendered, so assumed to be currently not relevant to the user).
Pseudo-elements with :content
are also already exposed in the accessibility tree. This feature will allow authors to fine-tune that process, by either marking them as not relevant for accessibility (by providing an empty string as the text alternative), or by providing a more useful string.
Discussed
May 1, 2019 (See Github)
Alice: Was just chatting with Sangwhan in Slack. I filed this review, so it sounds good to me, of course. Sangwhan had some good points. I think it's OK the way it is. This went through quite a bit of discussion in CSS WG. The proposal is to, in a content
property you can have a trailing slash following by a string, that will be treated as the alt text for the content where it at applies. Could be an element or a pseudo element, but with different rules. Sangwhan was proposing that wrapping the alt text in alt()
would make it more readable; like James Craig's proposal.
Sangwhan: My feedback would be as somebody who inherited code. Not obvious what it does with the /
syntax; alt()
would be much more obvious. James Craig raised a background compatibility issue. Peter, were you involved?
Peter: nothing significant to add
Dan: I haven't been involved in this work. Coming into it... haven't been involved in the review. I'm sure it's been discussed already. Doesn't this break the model where we have separation of content and presentation?
Alice: This is the fourth time I've had this conversation.
Dan: Maybe a couple sentences in the TAG review / minutes?
Alice: What I wrote: Anne filed a meta-issue about separation of style and content. I think it's a false dichotomy that accessibility tree, find-in-page, etc. [PASTE THIS IN LATER]
Alice: There's another issue on AOM... looking at standardizing how accessibility tree gets built. DOM semantics aren't the same as accessibility semantics. We prioritize keeping the a11y tree semantics as close to the default UI semantics as we feasibly can, with caveats where certain things don't map onto the AT paradigm. DOM semantics can provide good signal to intended semantics
Dan: [back to the order of constituents] the needs of the user outweigh ideological purity
David: separation was broken when content
was created. (Was intended for limited use.)
Sangwhan: The unfortunate reality is that there is a lot of content out there that uses this, which isn't accessible. This is a bug fix for that.
Dan: so are we done?
Alice: Sangwhan, Do you want to leave your feedback? I agree that alt()
syntax would look nicer. My inclination would be to take that back to CSS WG and see what they say.
Sangwhan: I think I should just at least write formal feedback on this, and then I'll do that.
Dan: close issue, or pending external feedback?
Sangwhan: I'll mark it pending after I write the content.
Alice: pending feedback from whom, CSS Working Group?
Sangwhan: yes
Dan: I'll set milestone to face-to-face.
Lukasz: Question about alternative text for accessibility. If it's intended for screenreaders if no image is being displayed, would you consider the image still be downloaded?
Alice:
Lukasz: Is it just a matter of display and the content is being downloaded regardless? It's a text to replace the image if one is using screenreader.
Alice: Your Concern about checking whether the image has been downloaded or not?
Lukasz: Is there established practice here that you're aware of?
Alice: In Chrome, typically, running assistive technology doesn't have any impact on whether images are downloaded or not. You could (if we still have a setting) turn off download of images, but we don't have any branching for how the page is rendered. The only thing that branches is whether we compute the a11y tree.
Lukasz: If someone wants to optimize things for screenreaders. If someone optimizes away then someone can see that user is using screenreader. Maybe spec should have a tip that this shouldn't be the case.
Alice: My hesitation is that most UAs would work this way anyway. If someone is using assistive technology we don't know why they're using it. They might see the screen but be using the accessibility infrastructure to run an input device. And there are screenreader users who are sighted as well; they might be able to see the image but not be able to read text well. Most user agents would be building for those use cases so there wouldn't be a risk that they would try to optimize downloads like that.
Lukasz: If this is so complex, how does the screenreader decide when to ... never mind about that?
Lukasz: Should I write a comment in the github and ask about it?
Alice: Sure... worst case we can reply on the github issue to explain the situation in case someone else comes across it.
Sangwhan: I don't think this particular issue is affected.
Alice: We can have this discussion in the github issue so it can be captured
Comment by @lknik May 1, 2019 (See Github)
Hi,
Looks like a useful addition for some. Following telecon discussion I've got a question. I'm not fully aware how all assistive technologies work (i.e. how the mode of operation functions). But I'm wondering whether if assistive tech is in use and enabled to work, browsers might (by default) choose to stop downloading the images, deferring to displaying the text only (i.e. a kind of optimization)? In that case it would potentially reveal that someone is using assistive tech.
If there is a hypothetical scenario of someone implementing this to work this way (when displaying alternative text, don't download the image), I'd consider if adding a tip/note explaining the potential risk wouldn't be a good idea. But as I likely do not have the required expertise in ATs, I am simply asking.
Comment by @alice May 1, 2019 (See Github)
@lknik Thanks for the comment!
I don't think this is ever likely to be a danger, as UAs have no way of knowing whether a user may or may not be able to see the image based on whether they are using a piece of software which accesses accessibility APIs. And even if we could tell that (which we can't), we wouldn't know whether they were likely sharing their screen with someone else at any given moment.
The use of accessibility APIs really seems like too weak a signal to use for such a drastic measure, compared to something like a user preference not to download images.
So I don't think it's worth warning against this case, though I do understand the concern.
Comment by @cynthia May 1, 2019 (See Github)
We discussed this in today's call, and the use cases are valid. There is obviously the philosophical question of separation of style and markup, and we are generally in agreement that putting content in style is suboptimal. That said, as unshipping content
is not really an option here, we would like to see this feature itself move forward.
Two points of feedback on the state of the spec:
- Backwards compatibility: This has been raised, but leaving this as it still is a valid issue. As long as a duplicate declaration for incompatible browsers is a reliably usable mechanism, we don't feel strongly against this. (On a side note, it being unergonomic could potentially promote content authors to do it in markup rather than content. Or at least one can hope.)
- Lack of a syntactic signifier of the purpose: This is a larger concern. In the current proposal, it is not obvious what the alt text declared in style is for. From a content author's perspective, the purpose of the
/ "something"
can be interpreted liberally (and is not obvious) on what purpose it serves; and this is concerning.
I would really like to see point 2 addressed. Without seeing this particular syntax (or looking up the relevant specs or MDN documentation) a content author who has inherited a stylesheet without being educated on the subject matter it wouldn't be obvious what purpose this serves. (and might end up deleting it, breaking accessibility)
Wrapping it around alt()
would make the purpose a lot more obvious. I believe this has been proposed within the CSSWG, and we'd like to see this revisited if possible.
Unrelated to TAG feedback, one question is whether or not it would be useful for the alt to be inheritable, but only change out the image. I'm suspecting the use cases would be rather slim but this is just out of curiosity.
Comment by @cynthia May 1, 2019 (See Github)
Forgot to mention @csswg-drafts. I'm not quite sure where to file the issues though, is it supposed to be here? https://github.com/w3c/csswg-drafts/labels/css-content-3
(Edited: Seems like @csswg-drafts is not a GH user. Hmm.)
Comment by @alice May 10, 2019 (See Github)
@dot-miniscule filed the issue on csswg-drafts: https://github.com/w3c/csswg-drafts/issues/3899
One relevant response, from @AmeliaBR:
[F]unctions in CSS serve to transform data, not to label it. Most functions can be used in many different properties, creating a new data type.
The alt() wrapper might help a developer understand unfamiliar code, but once they are familiar with it, it will just become extra characters to type.
(And quite frankly, the main obstacle to developer familiarity right now is lack of browser support!)
Comment by @AmeliaBR May 10, 2019 (See Github)
one question is whether or not it would be useful for the alt to be inheritable, but only change out the image.
The original proposal, to have a separate alt
property, would have supported this (and as a side effect, would have avoided backwards compatibility issues):
.warning::before {
content: url(scorpion.svg);
alt: "warning, ";
}
:lang(fr).warning::before {
alt: "attention, ";
}
[data-theme=simple] .warning::before {
content: "⚠";
}
But it was decided that this was an anti-pattern: the risk of content and alt text getting out of sync was considered more significant than the benefit of sometimes being able to apply the same alt text for different images or different alt text for the same images. As developers update their CSS, they could override content
with different selectors, but forget to override alt
to match.
See discussion here (and other replies in this thread), which seem to be the original source of the proposal to combine the alt text into the content
property: https://lists.w3.org/Archives/Public/www-style/2014Nov/0046.html
There is a follow-up explanation in this thread: https://lists.w3.org/Archives/Public/www-style/2016May/0103.html
I'm not 100% convinced that this justifies the loss of flexibility, but I agree that there are limitations either way. And with the current spec, if an author needs the same alt/image for multiple content declarations, it can be coordinated using CSS variables.
Discussed
Jun 1, 2019 (See Github)
Alice: last thing was - comment from Amelia - some questions from Sangwhan about alternatives considered. There was a proposal early on about wrapping the string in an alt function which would make the purpose more obvious. Amelia pointed out that it's noop function which is weird. And came back to this issue - which risks content and alt getting out of sync... I asked Sangwhan if he'd be OK closing it, he said OK.
Peter: we're ready to close this.
Dan: Sangwhan should close it because he's been active on the issue [and alice has a conflict of interest
Comment by @cynthia Jun 26, 2019 (See Github)
We've discussed this a couple calls ago, and concluded it is safe to close. Thanks for bringing this to our attention, and let us know how the content authors react to this when it ships.
OpenedMar 11, 2019
Góðan dag TAG!
I'm requesting a TAG review of:
Further details (optional):
You should also know that...
This has been part of the spec since 2016, but there is no evidence of a formal review process so it is being requested now.
We'd prefer the TAG provide feedback as (please select one):