10BC0 [css-color-5] relative color syntax doesn't specify how to compute channel keywords in other channels · Issue #8499 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content

[css-color-5] relative color syntax doesn't specify how to compute channel keywords in other channels #8499

@romainmenke

Description

@romainmenke

I might be overlooking something and I am not sure how to explain the issue fully.
So apologies in advance if this is a bit vague or if it was already answered.


I think there are a few things that are a bit hand-wavy in the current specification.

#a {
  color: rgb(from rgb(0 0 0 / 50%) alpha 128 128 / 0.1);
}

Safari TP and WPT seem to agree that this is : rgba(128, 128, 128, 0.1)
Somehow the alpha value of 50% or 0.5 got converted to 128.

This makes sense if you consider that 50% of 255 is 128.
But I don't think the specification mentions the need for this conversion anywhere.

https://drafts.csswg.org/css-color-5/#relative-RGB

alpha is a <number> that corresponds to the origin color’s alpha transparency

So alpha should be 0.5, not 128, when interpreting the specification naively.


#b {
  color: hsl(from rgb(128 128 128 / 50%) alpha 50% 50% / 0.1);
}

#c {
  color: hsl(0.5 50% 50% / 0.1);
}

#b seems to be rgb(0, 0, 0) (fallback to initial) but the reason isn't clear.
hsl should be able to process hue values of type <number>.

#c has the same number value as I would expect alpha to have and it works perfectly fine : rgba(191, 65, 64, 0.1).


What seems to be missing is a conversion table for when channel keywords are used in other channels.

  • using alpha in a r, g, b, h, ...
  • using r, g, ... in alpha
  • ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.css-color-5Color modification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0