Description
Since various UAs are currently implementing, it's imperative that we finalize the syntax of color-mix()
ASAP.
I've done a fair bit of editing and clearing up of that section recently, and the current grammar looks like this (note that the adjusters have been removed per editor resolution):
color-mix( in <<colorspace>> && [ [ <<color>> && [ <<percentage>> ]? ] <<color>> ])
Valid usage examples per this grammar:
color-mix(in lch red 20% white)
color-mix(in lch 20% red white)
color-mix(red 20% white in lch)
color-mix(20% red white in lch)
Invalid usage examples:
color-mix(red in lch 20% white)
color-mix(red 20% in lch white)
color-mix(in lch red white 20%)
In previous versions of color-mix()
, there were commas to separate the color space argument from the colors. After #6050 we resolved to remove that comma. However, since a comma is a "stronger" separator than a space, if we left the comma between colors, it would look as if the color space argument only applies to one of them:
color-mix(in lch red 20%, white)
So we removed that comma as well.
While I would strongly object to having a comma only to separate the colors but not the color space from the colors, I think the previous all-comma syntax was actually more readable:
color-mix(in lch, red 20%, white)
/* vs */
color-mix(in lch red 20% white)
OTOH this syntax allows for more flexibility in ordering the arguments.