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

[css-color-6] Behavior of color-contrast() when no level is specified #7556

Closed
LeaVerou opened this issue Aug 2, 2022 · 1 comment
Closed
Labels
a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. Closed Rejected as Wontfix by CSSWG Resolution css-color-6

Comments

@LeaVerou
Copy link
Member

LeaVerou commented Aug 2, 2022

Right now, if no level is specified, the behavior is that "the most contrasting color" is returned.
This essentially ignores the preference order the candidates are listed in and is vastly different from the behavior when a level is specified, breaking consistency. E.g. it makes color-contrast(over teal, white, black) the same as color-contrast(over teal, black, white).
What are the use cases where authors want the most contrasting color? Why not default to a reasonable (or even highest) level?

@LeaVerou LeaVerou added Agenda+ F2F a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. css-color-6 labels Aug 2, 2022
@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-color-6] Behavior of color-contrast() when no level is specified, and agreed to the following:

  • RESOLVED: no change
The full IRC log of that discussion <lea> topic: [css-color-6] Behavior of color-contrast() when no level is specified
<emilio> github: https://github.com//issues/7556
<emilio> lea: r/n per spec if no level is specified (wcag()), behavior is to get the most contrasting color, vs if you provide a level (wcag(aa)) you get the first that passes
<emilio> ... I think that's a bit inconsistent, ignores preference order
<emilio> ... not sure what use cases it covers
<chris> q+
<emilio> ... and is inconsistent with general use of functional notations where if you omit something it defaults to something
<emilio> ... so basically magic
<emilio> fantasai: no magic
<emilio> lea: it's magic in the sense that there's no way to pass an argument to do the same
<fantasai> emilio: I think I agree, either choosing a reasonable default or making the level mandatory are both reasonable options
<fantasai> astearns: ...
<emilio> astearns: are the levels fixed?
<fantasai> emilio: they depend on the algorithm
<emilio> astearns: seems slightly better in the sense that if we add a level behavior doesn't change?
<astearns> ack chris
<emilio> TabAtkins: not really, if we're choosing a default. I prefer making it mandatory because the level depends on your use case. People might not understand them but at least it's affirmative action, not "I wrote the shortest thing"
<lea> q?
<astearns> ack fantasai
<lea> q+ to say that people with dyslexia actually find very high contrasting text *harder* to read
<emilio> chris: You increase contrast so that legibility improves and reading speed improves, up to a point, so there's an argument to be made that there's an optimal contrast
<emilio> fantasai: but optimal isn't gonna be any of the minimums that we have here
<emilio> ... I think the behavior of picking the max is reasonable, and if we want a keyword we can add it
<emilio> ... and there are use cases for having a bunch of colors and picking the best, and define what an optimum contrast is not feasible
<emilio> ... so I'd rather stick with the max behavior, and if we want a max keyword I won't object
<emilio> chris: I don't think you really responded to my point
<astearns> ack dbaron
<emilio> fantasai: if you have infinite colors to choose from I agree with you, but we're choosing between two or maybe three colors from the author
<emilio> miriam: does this mean that on this case we won't ever fall back to white / black/
<emilio> *?
<emilio> fantasai: yes
<emilio> emilio: if you don't specify any color you pick between white / black right?
<emilio> fantasai: yes, if there's any color you choose between them
<emilio> dbaron: I think we're discussing two things
<emilio> ... one is that the syntax is confusing because it switches between modes
<emilio> ... the other is that the other mode is not useful
<emilio> ... one way to fix the former might be to have two different functions
<emilio> fantasai: I'm not sure they're sufficiently different
<astearns> ack lea
<Zakim> lea, you wanted to say that people with dyslexia actually find very high contrasting text *harder* to read
<emilio> ... I'm fine adding a max keyword
<fantasai> s/different/different to warrant 2 different functions
<emilio> lea: people with dyslexia actually find very high contrasting text harder to read, so more contrast might not be better
<emilio> ... but as una has mentioned already, authors not always want the best contrast
<emilio> ... they have preferences
<emilio> ... also I don't think authors will provide only a couple colors, but will choose a span of colors
<emilio> ... also it was pointed out that this mode is a bit inconsistent when where you specify a level you can always fall back to white and back
<emilio> ... like if you have blue and dark blue
<emilio> fantasai: that might be what you want if your color is not for text
<emilio> q+
<emilio> lea: but I think that default is not reasonable
<astearns> ack fantasai
<lea> s/the best contrast/the highest contrast/
<emilio> fantasai: if the author doesn't want maximal contrast they should not pass white/black to the list, this default always chooses one of the provided colors, is easy to understand
<emilio> ... you might not want the maximum contrast, but wanting the maximum inside a set is reasonable
<emilio> ... and getting the first that passes the bar might not always be what you want
<florian> q+
<emilio> astearns: if we go with what's specced now that's a lot easier to understand than picking a level and find a reference, and see why you're getting a particular color
<fantasai> emilio: I think we're in agreement that the mode that fantasai describes is reasonable
<fantasai> emilio: there are use cases for that, nobody's disagreeing right?
<fantasai> emilio: the question is whether it should be the default
<lea> wcag2(max) sounds like it gets you the maximum wcag contrast (21). Perhaps it should be a preamble modifier
<fantasai> emilio: It's a bit weird that you pass an argument and it changes, maybe we pass the algorithm as a keyword rather than a function? But I guess some algos want parameters...
<astearns> ack florian
<astearns> ack emilio
<emilio> florian: agree with fantasai that it's useful. I think either this is the default mode when there's no threshold, or there's no default and you must specify a threshold or invoke the mode with a keyword
<emilio> ... having something else be the default feels very arbitrary and possibly wrong
<fantasai> +1
<emilio> emilio: agree
<emilio> lea: one thing I pointed out in irc is that if we make it a max argument looks like it gives you a maximum contrast (21) which you can always get with white and black
<emilio> ... should it make a different modifier?
<lea> RESOLVED: no change
<emilio> fantasai: I propose we keep it the default and if we find a good syntax for that we do that
<florian> s/that it's useful/that it's a useful behavior/
<RRSAgent> I have made the request to generate https://www.w3.org/2022/08/02-css-minutes.html dbaron

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. Closed Rejected as Wontfix by CSSWG Resolution css-color-6
Projects
None yet
Development

No branches or pull requests

2 participants