Skip to content

Commit

Permalink
[css-values-5] Define inherit() for custom properties #2864
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasai committed Oct 28, 2024
1 parent 5666cec commit 6492353
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions css-values-5/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,37 @@ Custom Property References: the ''var()'' notation</h3>
see the <a href="https://www.w3.org/TR/css-variables/#using-variables">CSS Custom Properties for Cascading Variables Module</a>.
[[CSS-VARIABLES]]

<h3 id="inherit-notation">
Inherited Value References: the ''inherit()'' notation</h3>

Like the ''inherit'' keyword, the <dfn>inherit()</dfn> [=functional notation=]
resolves to the [=computed value=] of a property on the parent.
Rather than resolving to the value of the same property, however,
it resolves to the tokenized [=computed value=]
of the property specified as its first argument.
Its second argument, if present, is used as a fallback
in case the first argument resolves to the [=guaranteed-invalid value=].

''inherit()'' is an [=arbitrary substitution function=]
whose syntax is defined as:

<pre class=prod>
<dfn><<inherit()>></dfn> = inherit( <<custom-property-name>>, <<declaration-value>>? )
</pre>

To <dfn export>[=resolve an arbitrary substitution function|resolve an inherit() function=]</dfn>,
return the [=inherited value=] of the [=custom property=] specified by the first argument,
and (if specified) the fallback specified by the second argument.

Note: Future levels of CSS may allow specifying standard CSS properties in ''inherit()'';
however because the tokenization of [=computed values=]
is not fully standardized for all CSS properties,
this feature is deferred from Level 5.
Note that the [=computed value=] differs from the [=used value=],
and is not always the resolved value returned by {{getComputedStyle()}};
thus even if ''inherit(width)'' were allowed,
it would frequently return the keyword ''width/auto'', not the used <<length>>.

<!-- Big Text: attr()

███▌ █████▌ █████▌ ████▌ ██ ██
Expand Down

0 comments on commit 6492353

Please sign in to comment.