Skip to content

Commit f42236e

Browse files
andruudtabatkins
authored andcommitted
[css-properties-values-api] Describe substitution behavior. (w3c#863)
* [css-properties-values-api] Describe substitution behavior. * fixup.
1 parent 3c1cd1b commit f42236e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

css-properties-values-api/Overview.bs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,42 @@ declaration is <a spec=css-variables>invalid at computed-value time</a>.
767767

768768
Note: This applies regardless of whether or not the fallback is being used.
769769

770+
771+
Substitution {#substitution}
772+
----------------------------
773+
774+
Like unregistered custom properties, the value of a registered custom property
775+
can be substituted into another value with the ''var()'' function. However,
776+
registered custom properties substitute as their
777+
[[#calculation-of-computed-values|computed value]], rather than the original
778+
token sequence used to produce that value.
779+
780+
Any ''var()'' function that references a registered custom property must be
781+
replaced with an <dfn>equivalent token sequence</dfn>, which is equal
782+
to the token sequence that
783+
would have been produced by [[cssom#serialize-a-css-value|serializing]]
784+
the computed value, and [[css-syntax-3#tokenization|tokenizing]] the resulting
785+
string.
786+
787+
<div class='example'>
788+
Suppose that '--x' is registered with ''&lt;length>'' syntax, and that '--y'
789+
is an unregistered custom property.
790+
791+
<pre class='lang-css'>
792+
793+
div {
794+
font-size: 10px;
795+
--x: 8em;
796+
--y: var(--x);
797+
}
798+
</pre>
799+
800+
Because the computed value of '--x' (when serialized) is "80px", the computed
801+
value of '--y' is: <<whitespace-token>> followed by
802+
<<dimension-token>> with a value of '80' and unit 'px'.
803+
804+
</div>
805+
770806
Examples {#examples}
771807
====================
772808

0 commit comments

Comments
 (0)