- From: Valtteri Laitinen via GitHub <sysbot+gh@w3.org>
- Date: Fri, 14 Mar 2025 20:13:48 +0000
- To: public-css-archive@w3.org
valtlai has just created a new issue for https://github.com/w3c/csswg-drafts:
== [css-values-5] Allow `if()` in descriptors ==
Spec: https://drafts.csswg.org/css-values-5/#if-notation
Could we allow using the `if()` function in at-rule descriptors (if not already the case)?
My use case would be conditionally loading an hinted or unhinted font:
```css
@font-face {
font-family: 'The Font';
src: if(
media(resolution >= 2x): url(the-font-unhinted.woff2);
else: url(the-font-hinted.woff2)
);
}
```
Without `if()` support (or nesting support, see #11940), we have to needlessly repeat the unchanged descriptors:
```css
@media (resolution < 2x) {
font-family: 'The Font';
src: url(the-font-hinted.woff2);
}
@media (resolution >= 2x) {
font-family: 'The Font';
src: url(the-font-unhinted.woff2);
}
```
This isn’t DRY and is annoying when there are lot of `@font-face` rules.
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11941 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 14 March 2025 20:13:49 UTC