File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
css-properties-values-api Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -767,6 +767,42 @@ declaration is <a spec=css-variables>invalid at computed-value time</a>.
767767
768768Note: 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 ''<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+
770806Examples {#examples}
771807====================
772808
You can’t perform that action at this time.
0 commit comments