Re: [csswg-drafts] [css-mixins-1][css-values-5] The inherit() function in custom functions (#12987)

> Do we let both inherit and inherit() refer to the inherited value of the real element, and instead add a new keyword (+ function?) that refers to the calling stack frame? It weakens the "hyopthetical element" model, but perhaps this is the best move.

This is what I would expect as an author.

I am not sure if there are that many use cases for getting the values in the calling stack via `inherit()`?

It is already possible to access the values from the outer scope of the function (although, in a hacky way) via default values for optional arguments: https://codepen.io/kizu/pen/gbPqzMe

```CSS
@function --a() {
  --x: #F00;
  result: --b();
}
@function --b(--outer-x: var(--x)) {
  --x: #00F;
  result: color-mix(in srgb, var(--x), var(--outer-x));
}

.foo {
  background: --a();
  color: #FFF;
}
```

This produces a purple background, successfully mixing the `--x` from the `--a()` and `--x` from the `--b()`.

If there will be actual use cases provided for having a dedicated function/keyword referring to the calling stack frame — we could add it.

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


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

Received on Monday, 3 November 2025 23:54:03 UTC