Skip to content

[css-color-4] Expand the concept of analogous components to analogous sets of components to minimize none → 0 conversions #10210

Open

Description

@LeaVerou

(This came out of my comment here: #10151 (comment) )

Currently, css-color-4 defines that none values will be carried forward to analogous components. Basically, even when converting to different color spaces, if there are analogous components, they will become none.

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:

  1. Instead of analogous components, word the prose around analogous sets of components. The current analogous components are just sets of size 1.
  2. 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).
  3. The set of all components is analogous in every color space (basically [css-color-5] Colors where all channels (except) alpha have a value of none #10203 )

Not sure if this can be considered editorial, or we'd need WG resolution. @svgeesus ?

Activity

  1. 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
  2. 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
  3. LeaVerou commented on May 24, 2024

    @LeaVerou
    MemberAuthor

    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).

  4. css-meeting-bot commented on Jun 12, 2024

    @css-meeting-bot
    Member

    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
  5. svgeesus commented on Apr 17, 2025

    @svgeesus
    Collaborator

    @LeaVerou could you propose specific spec text? In particular I am not understanding "all components being none being analogous for all color spaces".

  6. LeaVerou commented on Apr 18, 2025

    @LeaVerou
    MemberAuthor

    @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%).

  7. yisibl commented on Apr 22, 2025

    @yisibl
    Contributor

    @LeaVerou As proposed here, the gradient below would render green?

    Currently Chrome, Safari, and Firefox all render as a black to green gradient.

    .test {
      background: linear-gradient(in oklab, rgb(none none none), green );
      width: 200px;
      height: 200px;
    }
  8. svgeesus commented on Apr 22, 2025

    @svgeesus
    Collaborator

    Currently Chrome, Safari, and Firefox all render as a black to green gradient.

    Right, because they are converting none to 0 too early

  9. romainmenke commented on Apr 22, 2025

    @romainmenke
    Member

    I am unsure if too early is the right way to describe this.
    They do follow the spec correctly in this case: https://drafts.csswg.org/css-color-4/#interpolation-missing

    In the course of converting the two colors to the interpolation color space, any missing components would be replaced with the value 0.

    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?

  10. svgeesus commented on Apr 22, 2025

    @svgeesus
    Collaborator

    I am unsure if too early is the right way to describe this.
    They do follow the spec correctly in this case: https://drafts.csswg.org/css-color-4/#interpolation-missing

    Yes, agreed. Hence this issue; the goal is to preserve none more than the current spec allows. So earlier than we want would be more precise.

    Is the proposed change (and resolution) still a change we can make given that there seems to be interop for the current specification?

    Not clear, but remains a possibility.

  11. 15 remaining items

  12. romainmenke commented on Jul 23, 2026

    @romainmenke
    Member

    should result in lch(none none none) and hwb(none none none)

    That is how I've implemented it.

    Note that hwb(none none none) is bright red and radically different from hsl(120deg none none) (as I also commented in #10210 (comment))

  13. facelessuser commented on Jul 23, 2026

    @facelessuser
    Contributor

    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.

    Image

    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.

    1. Accept that wb and cl don't have the same behavior, and you get what you get.
    2. Do not treat wb and cl as the same.
    3. 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.

  14. LeaVerou commented on Jul 23, 2026

    @LeaVerou
    MemberAuthor

    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.

  15. nex3 commented on Jul 23, 2026

    @nex3
    Contributor

    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.

  16. facelessuser commented on Jul 23, 2026

    @facelessuser
    Contributor

    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.

  17. nex3 commented on Jul 24, 2026

    @nex3
    Contributor

    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.

  18. facelessuser commented on Jul 24, 2026

    @facelessuser
    Contributor

    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.

  19. nex3 commented on Jul 30, 2026

    @nex3
    Contributor

    For the time being, I'll implement this as specified.

  20. moved this from Agenda+ to Thursday Morning in CSSWG summer 2026 meeting agendaon Aug 1, 2026
  21. css-meeting-bot commented on Aug 6, 2026

    @css-meeting-bot
    Member

    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?
  22. svgeesus commented on Sep 1, 2026

    @svgeesus
    Collaborator

    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?

  23. yisibl commented on Sep 30, 2026

    @yisibl
    Contributor

    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?

  24. romainmenke commented on Sep 30, 2026

    @romainmenke
    Member

    @yisibl I've openend a new issue for your question: #14543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

Sponsor
SponsoredKunjungi sekarang
Promo