Open LeaVerou opened 2 years ago
Considering there's been some WCAG3 discussion of maximum contrasts, too, e.g for large text...so as not to burn one's retinas :)
Maybe more than a single range syntax might be appropriate. Think some along the lines of min(), max(), minmax(), maxmin(), and clamp(). In the clamp(min, preferred, max) maybe even mid() for preferred.
Also perhaps consider a "by" increment, and or a "using" named-curve.
Feel free to separate any/all of these into their own issues.
Though not in color-6, some sort of element-level font-size query is also needed.
Hi Bill @BillGoldstein
...some WCAG3 discussion of maximum contrasts...
Yes, currently testing a maximum APCA contrast of what is currently calculated as Lc 90, this is on the live SAPC development tool along with a spread of use-case lookups.
There are a variety of factors that make a normative guideline for maximum contrast tricky:
So, at the moment, Lc 90 is an advisory maximum, especially in dark mode. But a better advisory MIGHT be, limit the color to no brighter than the equivalent of about #e6e6e6
A related advisory is for light mode, to keep the background under text to less than about #e6e6e6
as well.
Your mileage may vary, these values are under investigation.
Here's a visual example of some of the factors:
The CSS Working Group just discussed Ranges of Candidate Colors
, and agreed to the following:
RESOLVED: punt for now, revisit later
Color ranges, specifically using interpolation syntax with which authors will be familiar from gradients, sound like a neat way to derive a given color to achieve sufficient contrast from the base color (also captured in https://github.com/w3c/csswg-drafts/issues/5153).
Given there can't be any assumptions about the monotonicity of contrast, so binary search is unhelpful, would it make sense to allow authors to define the number of samples the range computes to, with a default that makes it reasonable to evaluate the list from start to end against one or more contrast targets? And possibly an upper limit so author's can't inadvertently degrade performance on less powerful devices?
Something along the lines of:
range(<number>? <interpolation-method>, <color>#)
When designers are picking colors to pass a certain contrast ratio, they usually adjust a given coordinate, in a given color space (usually lightness). The current
color-contrast()
syntax only allows providing specific candidate colors, so I worry we will see a lot of this:It would be good if there was a syntax to provide the candidate colors as a range, either by reusing
<gradient>
, or with a watered down microsyntax:range(<interpolation-method>, <color>#)
range(in lch, lch(from var(--color) 100% c h), lch(from var(--color) 0% c h))
)<color> to <color> <interpolation-method>?
lch(from var(--color) 100% c h) to lch(from var(--color) 0% c h) in lch
The range would be considered ordered, and browsers would return the first color in the range that passes the target contrast (which they may decide to calculate via binary search). It may make things simpler if ranges can only be from one color to another color.
(Issue filed following breakout discussions between @svgeesus, @fantasai, @argyleink and myself)