- From: Chris Lilley via GitHub <sysbot+gh@w3.org>
- Date: Mon, 16 Sep 2024 16:53:10 +0000
- To: public-css-archive@w3.org
Good question, and the answer is a bit more complicated than a simple yes or no. We now define a [legacy color syntax](https://drafts.csswg.org/css-color-4/#color-syntax-legacy), which originally was simply a comma vs space-and-slash difference. On the positive side, the legacy syntaxes are implemented widely and reach back to earlier browser versions so content developers who are required to support incredibly old browser versions for whatever reason are advised to use them. That broad support is also why we [serialize in legacy syntax](https://drafts.csswg.org/css-color-4/#css-serialization-of-srgb), using either `rgb()` or `rgba()` depending on whether the alpha is exactly one. That maximizes compatibility with older scripts that assume `rgb()` never has alpha, for example. For similar backwards-compatibility reasons, we ensure that component values which _can_ be exactly serialized as integer _are_ serialized that way. On the negative side, there is an [increasing list of things](https://drafts.csswg.org/css-color-4/#color-syntax-legacy) that modern color syntax can do, which legacy syntax cannot: - can't use `none` for missing values (0 is used instead) - can't mix percent and number, must use one or the other - don't reliably preserve more than 8 bits per component That list gets bigger in [CSS Color 5, relative colors](https://drafts.csswg.org/css-color-5/#relative-colors) - [relative colors](https://drafts.csswg.org/css-color-5/#relative-syntax) can only use the modern syntax (although the origin color can use any syntax, including legacy) And thus, for new color syntaxes that don't have a web-compat legacy, we _only_ define the modern syntax because we expect all of these additional things to always work. Moving on to your specific questions: > Are `rgba()` and `hsla()` already deprecated? Remember, deprecated means "don't use in new content" not "will stop working". So they can certainly continue to be used, even if we did deprecate them, which we have not. Provided that none of the new features are needed. > Should we ask developers not to use them in new code? If it doesn't make a difference then **yes**, encourage new developers, and developers of new code, to use the modern syntax. That way, if they want to set an `hsl()` hue to missing, or want to make a new `hsl()` color using calc, they don't need to discover that it doesn't work (and that the fix, mysteriously, is to get rid of commas). -- GitHub Notification of comment by svgeesus Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10886#issuecomment-2353436246 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 16 September 2024 16:53:11 UTC