Re: [csswg-drafts] [css-values-4] inherit() function: like var() for parent value, for any property (#2864)

Had thought about it a bit more. Main issue with `inherit` vs `parent` if we'd want to use it for things that are _not_ inherited (like using the padding to define a negative margin of the same size etc) is that with `inherit` we actually _could not_ use non-inherited values.

```html
<ul style="padding: 10px;">
  <li style="margin-left: calc(-1 * inherit(padding-left))">
```

In the above, on the `li` there is no really inherited value of the padding, as `li` does not inherit it from `ul`. But if we'd do

```html
<ul style="padding: 10px;">
  <li style="margin-left: calc(-1 * inherit(padding-left)); padding: inherit;">
```

then it actually would be inherited, _but_ this both looks weird, and also not something that someone would want to do, as almost always we would want to actually have an ability to define the padding on this element.

The fact that this would work with the custom properties would be more of a coincidence — because they're inherited by default, this would usually work (unless we'd disable the inheritance via `@property`).

So while we _want_ to make `margin-left: calc(-1 * inherit(padding-left));` work as is — getting the `padding` value from the parent _even though it is not inherited_, we would in some way break the existing meaning of CSS inheritance.

Thus, if one of the use-cases would be to use the actual parent's value without inheritance, the `parent` now seems like a better choice, and it would have a different, not yet existing definition of something like

> `parent(property)` - take the value of this property as if it was inherited to this element, regardless of it is actually inherited

This way it:

1. Could be used to get values of non-inherited values, like `padding`, or custom properties with `inherits: false`.
2. Would still logically work for inherited properties.

Because of this “as if” for inheritance, and not actually using the inheritance, having the `inherit` in the name could be incorrect.

Adding just `inherit` for the first iteration with only CSS variables — I still think using `parent` for this is better, as in the future the `inherit` would be useless on its own (I can't really see any uses for it if we'd have both it and `parent` at the same time).

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


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

Received on Monday, 30 January 2023 21:47:18 UTC