You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-color-4] Expand the concept of analogous components to analogous sets of components to minimize none → 0 conversions #10210
Essentially what this does, is attempt to divide the components into rough sets of dependencies and try to preserve author intent as much as possible.
Sure, they’re not entirely orthogonal, and e.g. tweaking hue in HSL does affect chroma and lightness in oklch, but it's the lesser of two evils, the other evil being converting none to 0.
To that goal, I can see a few improvements we can make to minimize none → 0 conversions even more:
Instead of analogous components, word the prose around analogous sets of components. The current analogous components are just sets of size 1.
If two color spaces have analogous components, the components remaining after you remove all analogous components, are an analogous set. Meaning, if Lab L is analogous to OKLch L, this means Lab a,b are analogous to OKLCh c, h., so converting e.g. oklch(50% none none) to lab yields lab(42 none none).
changed the title [-][css-color-4] Expand the concept of analogous components to analogous _sets_ of components to minimize `none` → `0` conversions[/-][+][css-color-4] Expand the concept of analogous components to analogous *sets* of components to minimize `none` → `0` conversions[/+]on Apr 15, 2024
changed the title [-][css-color-4] Expand the concept of analogous components to analogous *sets* of components to minimize `none` → `0` conversions[/-][+][css-color-4] Expand the concept of analogous components to analogous sets of components to minimize `none` → `0` conversions[/+]on Apr 15, 2024
I actually just realized a pretty important reason to do this: it means the result can be consistent regardless of the conversion path.
For example, let’s take a conversion from sRGB to LCh.
The conversion path using XYZ D65 as a connection space is as follows: sRGB → Linear sRGB → XYZ D65 → XYZ D50 → Lab → LCH
Suppose we’re converting white. white in XYZ D50 is color(xyz-d50 0.9643 1 0.8251) which is lab(100 none none).
a and b have no analogous components, so when converted to LCh they are converted to lch(100 0 0).
However, if we consider them an analogous set, then can be converted to lch(100 none none).
The CSS Working Group just discussed [css-color-4] Expand the concept of analogous components to analogous sets of components to minimize `none` → `0` conversions, and agreed to the following:
RESOLVED: Also any set of analogous components are
The full IRC log of that discussion
<fantasai> lea: mapping between components of analogous color spaces is well-defined in the spec
<fantasai> lea: e.g. mapping green to green, ligthness to lightness, etc.
<fantasai> lea: if analogous component exists in other color space, after conversion none is preserved
<fantasai> lea: we convert none to zero, and then convert, and then put none back
<fantasai> lea: want to expand the idea
<fantasai> lea: if lightness is none and convert from labl to oklch
<fantasai> lea: lightness is still none
<fantasai> lea: but if lightness is a specific number and a/b are none they would become zero
<fantasai> lea: what this concept defines is .. if you split the components into sets that correspond
<fantasai> lea: then what remains is also analogous
<fantasai> lea: so a+b is analogous to c+h
<fantasai> lea: this mainly makes a difference for lab to lch
<fantasai> lea: or colors where all are none
<fantasai> lea: that would be an analogous set
<fantasai> lea: that's logically consistent
<dbaron> makes sense
<fserb> q+
<lea> q?
<fantasai> fserb: will you describe in the spec in those terms, or actually list all the combinations?
<ChrisL> I think these analogous sets make sense
<dbaron> (it doesn't sound to me like there's much of an explosion... I think)
<fantasai> lea: combinatorial explosion. So anything that remains after subtracting the analogous components is (as a set) an analogous component
<lea> PROPOSED RESOLUTION: Expand concept of analogous components to analogous *sets* of components.
<fantasai> PROPOSED: The components that remain after removing the anlogous components are (as a set) an analogous component.
<dbaron> (including all components being none being analogous for all color spaces)
<fserb> +1
<fantasai> RESOLVED: Also any set of analogous components are
@LeaVerou could you propose specific spec text? In particular I am not understanding "all components being none being analogous for all color spaces".
I’ll need to think more about specific spec text but that sentence basically means that if all three components are none, then all components of the resulting color are none regardless of what the source and destination color space is. E.g. rgb(none none none / 50%) becomes oklab(none none none / 50%).
Thus, the first stage in interpolating two colors is to classify any missing components in the input colors, and compare them to the components of the interpolation color space. If any analogous components which are missing components are found, they will be carried forward and re-inserted in the converted color before premultiplication, and before linear interpolation takes place.
Because there are no analogous components between rgb and oklch, nothing is carried forward and re-inserted. Interpolating with black is correct as per the current specification.
Or is there another part of the specification that also comes into play and that makes the current implementation incorrect?
Is the proposed change (and resolution) still a change we can make given that there seems to be interop for the current specification?
Yeah, wb and cl are analogous in what they control, but not in how they control it. The more liberally you associate channels as being the same, the more this will occur, especially if the default for undefined is always zero.
A default of zeros in wb means fully chromatic and very bright, and a default of zeros in cl means achromatic and dark. Unless you are willing to give them context-specific defaults to mean achromatic and dark, they will be different.
That said, it does seem a bit unintuitive that the hue would be lost here
Hue is usually lost if there is no chroma, and sometimes when lightness is zero in some spaces. Carrying forward exact hue is nearly impossible except in spaces where hue means the exact same thing: hsl and hwb. Hue doesn't mean the same thing when compared to LCh or OkLCh and will be lost there if there is no context of chroma.
I think having lch(none none none) translate to hwb(none none none) seems fine, especially when all channels are grouped together as a whole. You didn't have a defined color to start with, so when it does get defined, you get what you get in the context of the color space that is finally rendered.
wb and cl aren't really the same thing, and their assumed defaults influence the significance of the hue. They control everything that is not a hue, but do so very differently. They are similar in control, but not in behavior.
That only leaves you with a few choices.
Accept that wb and cl don't have the same behavior, and you get what you get.
Do not treat wb and cl as the same.
Give them context-specific defaults that mean something similar (I don't expect CSS will do this).
I've often felt that if you are meaningfully trying to work with none you should do so in the context of the space you are working within, hue being the exception. Carrying none across spaces can work okay where channels have a similar enough meaning and behavior (sRGB blue is not the same as Rec 2020 blue, but they are both blue), but in cases like wb and cl, I kind of feel you get what you get if you want those to be carried over.
Another question: what are the expected outcomes of converting hsl(120deg none none) to LCH and HWB? By my reading of the spec (given that conversion should forward analogous components), these should result in lch(none none none) and hwb(none none none)—the chroma/hue being none because the saturation and lightness are both powerless, and the actual hue information is lost in the initial conversion to sRGB. That said, it does seem a bit unintuitive that the hue would be lost here (especially in the HSL -> HWB conversion where there's an unambiguous answer; HSL -> LCH is squishier given that multiple colors with the same HSL hue can map onto a range of different LCH hues), so I wanted to check that this was the intent before implementing.
That should be an easy fix, since analogous components are plugged in at the end of the conversion, so we can just say that it applies to the start and end space, not intermediate ones.
The issue isn't necessarily pulling the missing components through intermediate spaces, it's that if you default them to 0 you get hsl(120deg 0% 0%) which converts to color(srgb 0 0 0) which converts to hwb(0deg 0% 0%) which is then normalized to hwb(none 0% 0%) because the hue is powerless. You'd need some explicit way of bringing forward the hue to avoid this.
The issue isn't necessarily pulling the missing components through intermediate spaces, it's that if you default them to 0 you get hsl(120deg 0% 0%) which converts to color(srgb 0 0 0) which converts to hwb(0deg 0% 0%) which is then normalized to hwb(none 0% 0%) because the hue is powerless. You'd need some explicit way of bringing forward the hue to avoid this.
At least with hsl and hwb, you could special case this as the hue is the same for hsl and hwb, but this is only because these models are based on the same hue calculations. As soon as you convert these to LCh and OkLCh, there is no preserving hue without having the full context of the color; that is just the nature of how the perceptual color models work. A hue of 300 in hsl could be a range of different hues in LCh or OkLCh depending on the lightness and saturation.
Undefined hues have consequences during conversions. If you don't force them to a default, they become infectious, and if you do, you assume some default which can change values during conversions. If you happen to know the relationship some of the spaces during conversion, you can certainly make special decisions and maybe preserve certain attributes, but it will not consistently translate with all conversions.
The same is generally true for forwarding missing channels; the green in color(srgb none 0.5 none) could be a range of different greens in display-p3, but in practice it converts to color(display-p3 none 0.492248193 none) because missing channels are treated as 0 during conversion. One could imagine a decision to special-case hue/chroma-only color conversions such that they result in a similar arbitrary-but-reasonable output.
To be clear, I'm not advocating for that decision; I think either option is reasonable. I just want to highlight it as a potential sharp edge and get an informal signal on whether or not it's likely to change so I can implement the behavior that's considered "intended" going forward.
The same is generally true for forwarding missing channels; the green in color(srgb none 0.5 none) could be a range of different greens in display-p3, but in practice it converts to color(display-p3 none 0.492248193 none) because missing channels are treated as 0 during conversion.
It's a bit worse, probably for hues. There are times when red would translate to orange or blue to purple, but to be fair, I haven't really compared such impacts to any great extent.
To be clear, I'm not advocating for that decision; I think either option is reasonable.
Yep, I'm also not really pushing for a specific direction. I figure the more details on the table, the better the decision that could be made.
The CSS Working Group just discussed [css-color-4] Expand the concept of analogous components to analogous sets of components to minimize `none` → `0` conversions.
The full IRC log of that discussion
<TabAtkins> ChrisL: sometimes analogous sets of components work weird
<TabAtkins> ChrisL: if one component is 0-1 range and the other is 0-100 range, copying over doesn't do what you expect
<TabAtkins> lea: do we have in the spec that hwb goes thru rgb in the spec?
<TabAtkins> lea: they're saying that going to rgb loses powerless components, so you lose the idea that the hue is powerless
<romain> q+
<TabAtkins> lea: but I thought we already looked for the analogous things
<TabAtkins> ChrisL: I also thought that
<astearns> ack romain
<TabAtkins> romain: quick response, we only transfer the missing components, not actual values
<TabAtkins> romain: so if you have meaningful hue of 70deg, you don't transfer it. only none/powerless are carried over
<TabAtkins> [garbled conversation]
<TabAtkins> astearns: should we discuss powerlessness in another issue?
<TabAtkins> astearns: for the time being we should bring this up in another issue
<TabAtkins> astearns: maybe get nat to come to a meeting we can discuss this in, when we're ready?
I'd like to know under what circumstances “none” can be safely converted to 0, as this is very useful for CSS minifiers.
e.g.
.foo{background:linear-gradient(in oklab,rgb(none none none), green );}
This cannot be converted to linear-gradient(in oklab, #000, green) in a gradient.
But background-color: rgb(none none none) can safely be converted to background-color: #000, right?
Activity
[-][css-color-4] Expand the concept of analogous components to analogous _sets_ of components to minimize `none` → `0` conversions[/-][+][css-color-4] Expand the concept of analogous components to analogous *sets* of components to minimize `none` → `0` conversions[/+][-][css-color-4] Expand the concept of analogous components to analogous *sets* of components to minimize `none` → `0` conversions[/-][+][css-color-4] Expand the concept of analogous components to analogous sets of components to minimize `none` → `0` conversions[/+]LeaVerou commentedon May 24, 2024
I actually just realized a pretty important reason to do this: it means the result can be consistent regardless of the conversion path.
For example, let’s take a conversion from sRGB to LCh.
The conversion path using XYZ D65 as a connection space is as follows: sRGB → Linear sRGB → XYZ D65 → XYZ D50 → Lab → LCH
Suppose we’re converting
white.whitein XYZ D50 iscolor(xyz-d50 0.9643 1 0.8251)which islab(100 none none).a and b have no analogous components, so when converted to LCh they are converted to
lch(100 0 0).However, if we consider them an analogous set, then can be converted to
lch(100 none none).css-meeting-bot commentedon Jun 12, 2024
The CSS Working Group just discussed
[css-color-4] Expand the concept of analogous components to analogous sets of components to minimize `none` → `0` conversions, and agreed to the following:RESOLVED: Also any set of analogous components areThe full IRC log of that discussion
<fantasai> lea: mapping between components of analogous color spaces is well-defined in the spec<fantasai> lea: e.g. mapping green to green, ligthness to lightness, etc.
<fantasai> lea: if analogous component exists in other color space, after conversion none is preserved
<fantasai> lea: we convert none to zero, and then convert, and then put none back
<fantasai> lea: want to expand the idea
<fantasai> lea: if lightness is none and convert from labl to oklch
<fantasai> lea: lightness is still none
<fantasai> lea: but if lightness is a specific number and a/b are none they would become zero
<fantasai> lea: what this concept defines is .. if you split the components into sets that correspond
<fantasai> lea: then what remains is also analogous
<fantasai> lea: so a+b is analogous to c+h
<fantasai> lea: this mainly makes a difference for lab to lch
<fantasai> lea: or colors where all are none
<fantasai> lea: that would be an analogous set
<fantasai> lea: that's logically consistent
<dbaron> makes sense
<fserb> q+
<lea> q?
<fantasai> fserb: will you describe in the spec in those terms, or actually list all the combinations?
<ChrisL> I think these analogous sets make sense
<dbaron> (it doesn't sound to me like there's much of an explosion... I think)
<fantasai> lea: combinatorial explosion. So anything that remains after subtracting the analogous components is (as a set) an analogous component
<lea> PROPOSED RESOLUTION: Expand concept of analogous components to analogous *sets* of components.
<fantasai> PROPOSED: The components that remain after removing the anlogous components are (as a set) an analogous component.
<dbaron> (including all components being none being analogous for all color spaces)
<fserb> +1
<fantasai> RESOLVED: Also any set of analogous components are
svgeesus commentedon Apr 17, 2025
@LeaVerou could you propose specific spec text? In particular I am not understanding "all components being none being analogous for all color spaces".
LeaVerou commentedon Apr 18, 2025
I’ll need to think more about specific spec text but that sentence basically means that if all three components are
none, then all components of the resulting color arenoneregardless of what the source and destination color space is. E.g.rgb(none none none / 50%)becomesoklab(none none none / 50%).yisibl commentedon Apr 22, 2025
@LeaVerou As proposed here, the gradient below would render
green?Currently Chrome, Safari, and Firefox all render as a black to green gradient.
svgeesus commentedon Apr 22, 2025
Right, because they are converting
noneto0too earlyromainmenke commentedon Apr 22, 2025
I am unsure if
too earlyis the right way to describe this.They do follow the spec correctly in this case: https://drafts.csswg.org/css-color-4/#interpolation-missing
Because there are no analogous components between rgb and oklch, nothing is carried forward and re-inserted. Interpolating with black is correct as per the current specification.
Or is there another part of the specification that also comes into play and that makes the current implementation incorrect?
Is the proposed change (and resolution) still a change we can make given that there seems to be interop for the current specification?
svgeesus commentedon Apr 22, 2025
Yes, agreed. Hence this issue; the goal is to preserve
nonemore than the current spec allows. Soearlier than we wantwould be more precise.Not clear, but remains a possibility.
[css-color-4] Expand analogous components to analogous sets to minimi…
15 remaining items
romainmenke commentedon Jul 23, 2026
That is how I've implemented it.
Note that
hwb(none none none)is bright red and radically different fromhsl(120deg none none)(as I also commented in #10210 (comment))facelessuser commentedon Jul 23, 2026
Yeah,
wbandclare analogous in what they control, but not in how they control it. The more liberally you associate channels as being the same, the more this will occur, especially if the default for undefined is always zero.A default of zeros in
wbmeans fully chromatic and very bright, and a default of zeros inclmeans achromatic and dark. Unless you are willing to give them context-specific defaults to mean achromatic and dark, they will be different.Hue is usually lost if there is no chroma, and sometimes when lightness is zero in some spaces. Carrying forward exact hue is nearly impossible except in spaces where hue means the exact same thing:
hslandhwb. Hue doesn't mean the same thing when compared to LCh or OkLCh and will be lost there if there is no context of chroma.I think having
lch(none none none)translate tohwb(none none none)seems fine, especially when all channels are grouped together as a whole. You didn't have a defined color to start with, so when it does get defined, you get what you get in the context of the color space that is finally rendered.wbandclaren't really the same thing, and their assumed defaults influence the significance of the hue. They control everything that is not a hue, but do so very differently. They are similar in control, but not in behavior.That only leaves you with a few choices.
wbandcldon't have the same behavior, and you get what you get.wbandclas the same.I've often felt that if you are meaningfully trying to work with
noneyou should do so in the context of the space you are working within, hue being the exception. Carryingnoneacross spaces can work okay where channels have a similar enough meaning and behavior (sRGB blue is not the same as Rec 2020 blue, but they are both blue), but in cases likewbandcl, I kind of feel you get what you get if you want those to be carried over.LeaVerou commentedon Jul 23, 2026
That should be an easy fix, since analogous components are plugged in at the end of the conversion, so we can just say that it applies to the start and end space, not intermediate ones.
nex3 commentedon Jul 23, 2026
The issue isn't necessarily pulling the missing components through intermediate spaces, it's that if you default them to 0 you get
hsl(120deg 0% 0%)which converts tocolor(srgb 0 0 0)which converts tohwb(0deg 0% 0%)which is then normalized tohwb(none 0% 0%)because the hue is powerless. You'd need some explicit way of bringing forward the hue to avoid this.facelessuser commentedon Jul 23, 2026
At least with hsl and hwb, you could special case this as the hue is the same for hsl and hwb, but this is only because these models are based on the same hue calculations. As soon as you convert these to LCh and OkLCh, there is no preserving hue without having the full context of the color; that is just the nature of how the perceptual color models work. A hue of 300 in hsl could be a range of different hues in LCh or OkLCh depending on the lightness and saturation.
Undefined hues have consequences during conversions. If you don't force them to a default, they become infectious, and if you do, you assume some default which can change values during conversions. If you happen to know the relationship some of the spaces during conversion, you can certainly make special decisions and maybe preserve certain attributes, but it will not consistently translate with all conversions.
nex3 commentedon Jul 24, 2026
The same is generally true for forwarding missing channels; the green in
color(srgb none 0.5 none)could be a range of different greens indisplay-p3, but in practice it converts tocolor(display-p3 none 0.492248193 none)because missing channels are treated as 0 during conversion. One could imagine a decision to special-case hue/chroma-only color conversions such that they result in a similar arbitrary-but-reasonable output.To be clear, I'm not advocating for that decision; I think either option is reasonable. I just want to highlight it as a potential sharp edge and get an informal signal on whether or not it's likely to change so I can implement the behavior that's considered "intended" going forward.
facelessuser commentedon Jul 24, 2026
It's a bit worse, probably for hues. There are times when red would translate to orange or blue to purple, but to be fair, I haven't really compared such impacts to any great extent.
Yep, I'm also not really pushing for a specific direction. I figure the more details on the table, the better the decision that could be made.
nex3 commentedon Jul 30, 2026
For the time being, I'll implement this as specified.
css-meeting-bot commentedon Aug 6, 2026
The CSS Working Group just discussed
[css-color-4] Expand the concept of analogous components to analogous sets of components to minimize `none` → `0` conversions.The full IRC log of that discussion
<TabAtkins> ChrisL: sometimes analogous sets of components work weird<TabAtkins> ChrisL: if one component is 0-1 range and the other is 0-100 range, copying over doesn't do what you expect
<TabAtkins> lea: do we have in the spec that hwb goes thru rgb in the spec?
<TabAtkins> lea: they're saying that going to rgb loses powerless components, so you lose the idea that the hue is powerless
<romain> q+
<TabAtkins> lea: but I thought we already looked for the analogous things
<TabAtkins> ChrisL: I also thought that
<astearns> ack romain
<TabAtkins> romain: quick response, we only transfer the missing components, not actual values
<TabAtkins> romain: so if you have meaningful hue of 70deg, you don't transfer it. only none/powerless are carried over
<TabAtkins> [garbled conversation]
<TabAtkins> astearns: should we discuss powerlessness in another issue?
<TabAtkins> astearns: for the time being we should bring this up in another issue
<TabAtkins> astearns: maybe get nat to come to a meeting we can discuss this in, when we're ready?
svgeesus commentedon Sep 1, 2026
So currently, the spec defines:
we clarified the steps for interpolation and these are backed up by new WPT tests for powerless and
none@LeaVerou @nex3 is everything clear now? If not, what remains for this issue?
yisibl commentedon Sep 30, 2026
I'd like to know under what circumstances “none” can be safely converted to 0, as this is very useful for CSS minifiers.
e.g.
This cannot be converted to
linear-gradient(in oklab, #000, green)in a gradient.But
background-color: rgb(none none none)can safely be converted tobackground-color: #000, right?romainmenke commentedon Sep 30, 2026
@yisibl I've openend a new issue for your question: #14543