Re: [csswg-drafts] [css-color] Should specify that `opacity` is serialized as a number for the specified values (#10426)

> [@svgeesus](https://github.com/svgeesus) I don't think this part is needed:

We already say the same thing in Serializing `<color>` valueshttps://drafts.csswg.org/css-color-4/#serializing-color-values) so I added it for `opacity`, too.

> The current [WPT tests](https://wpt.fyi/results/css/css-color/parsing/opacity-valid.html) have a pretty weird assumption that calc() values with percentages get transformed into calc() values with numbers:

Probably because the [spec says](https://drafts.csswg.org/css-color-4/#serializing-opacity-values) 

> The specified given opacity value is serialized as a [`<number>`](https://drafts.csswg.org/css-values-4/#number-value), not a [`<percentage>`](https://drafts.csswg.org/css-values-4/#percentage-value).

So I guess the disconnect is whether to resolve the percentages in specified values, or only in computed values. And whether that happens before or after `calc()` processing. I can see the value in retaining `<percentage>` inside calc.

For color components, we [also serialize to `<number>`](https://drafts.csswg.org/css-color-4/#serializing-color-function-values):

> The component values are serialized in base 10, as [`<number>`](https://drafts.csswg.org/css-values-4/#number-value).

The text you propose seems clear. @emilio is there a reason for the Firefox behavior, and if no strong reason, can it be changed for interop?

-- 
GitHub Notification of comment by svgeesus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10426#issuecomment-2886840337 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 16 May 2025 14:11:55 UTC