You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<dd>A variable whose value is a single <i>CSSFOO</i>, such as a keyword (like ''red''), a dimension (like ''20px''), or a function (like ''linear-gradient(red,blue)'').</dd>
<dd>A variable whose value is multiple <i>CSSFOO</i>s separated by spaces or other separators, such as commas or slashes, like ''red, blue, white''.</dd>
167
-
</dl>
168
-
169
-
<pclass='issue'>What term can I use for <dfn>CSSFOO</dfn>? It looks like it corresponds to "term" in the 2.1 grammar.</p>
170
-
171
153
<h2id='using-variables'>
172
154
Using Variables</h2>
173
155
174
156
<p>A variable can be used anywhere a value is expected in CSS. Variables can not be used as property names, selectors, or anything else besides property values - doing so either produces an invalid value or, in some situations like the attribute value of an attribute selector, a valid value that nonetheless has no relation to the variable of that name.</p>
175
157
176
-
<p>A variable is substituted for its value in the property value at computed-value time.</p>
177
-
178
-
<p><i>Singular variables</i> can be used anywhere as a value. They can be an entire property's value, a component value in a larger property value, an argument to a function, etc.. <i>Compound variables</i> are somewhat more restricted - they can only be used as an entire property value, a whole component of a list-valued property, or a whole function argument. <i>List variables</i> are the most restricted - they can only be used as an entire property value, as one or more whole components of a list-valued property, or as a whole series of function arguments.</p>
158
+
<p>A variable is substituted for its value in the property value at computed-value time. If the property value, once all variables are substituted in, is invalid for the property, that is an <i>invalid variable use</i>.</p>
179
159
180
-
<divclass='example'>
181
-
<p>Here are some examples of valid and invalid use of a <i>compound variable</i>:</p>
182
-
183
-
<pre>
184
-
@var $compound 20px 30px;
185
-
div {
186
-
margin: $compound;
187
-
/* Valid, as it's used as a whole property value */
188
-
/* Equivalent to "margin: 20px 30px;" */
189
-
190
-
text-shadow: $compound blue;
191
-
/* Invalid, as it's not used as a whole property value */
192
-
193
-
background-position: 10px 10px, $compound, 50px;
194
-
/* Valid, as it's used as a whole component of a list-valued property */
195
-
/* Equivalent to "background-position: 10px 10px, 20px 30px, 50px;" */
/* Invalid, as it's not used as a whole sequence of function arguments */
225
-
}</pre>
226
-
</div>
227
-
228
-
<p>Using a <i>compound variable</i> or <i>list variable</i> in an invalid way is an <i>invalid variable use</i>.</p>
229
-
230
-
<p>Similarly, if a property containing a variable in its property value ends up being invalid when the variable's value is substituted in, that is an <i>invalid variable use</i>.</p>
231
-
232
-
<divclass='example'>
160
+
<divclass='example'>
233
161
<p>For example, the following usage is fine from a syntax standpoint, but results in nonsense when the variable is substituted in:</p>
234
162
235
163
<pre>
@@ -242,9 +170,9 @@ <h2 id='using-variables'>
242
170
<h3id='using-invalid-variables'>
243
171
Using Invalid Variables</h3>
244
172
245
-
<p>An <dfntitle="invalid variable|invalid variables">invalid variable</dfn> results from having variables directly or indirectly refer to themselves. Using an <i>invalid variable</i> results in an <i>invalid variable use</i>.</p>
173
+
<p>An <dfntitle="invalid variable|invalid variables">invalid variable</dfn> results from having variables directly or indirectly refer to themselves, or from using an undefined variable. Using an <i>invalid variable</i> results in an <i>invalid variable use</i>.</p>
246
174
247
-
<p>An <dfn>invalid variable use</dfn> results from either using an <i>invalid variable</i>, or using a <i>compound variable</i> or <i>list variable</i> in an invalid way. When this happens, the property the variable is used in must compute to the property's initial value.</p>
175
+
<p>An <dfn>invalid variable use</dfn> results from either using an <i>invalid variable</i> in a property value, or using a valid variable that produces an invalid property value when it is substituted in. When this happens, the property the variable is used in must compute to the property's initial value.</p>
<p>the <p> elements will have transparent backgrounds (the initial value for 'background-color'), rather than red text.</p>
185
+
<p>the <p> elements will have transparent backgrounds (the initial value for 'background-color'), rather than red backgrounds.</p>
258
186
</div>
259
187
260
-
<pclass='note'>The <i>invalid variable use</i> concept exists because variables can't "fail early" like other syntax errors can, so by the time the user agent realizes a variable is invalid, it's already thrown away the other cascaded values.</p>
188
+
<pclass='note'>The <i>invalid variable use</i> concept exists because variables can't "fail early" like other syntax errors can, so by the time the user agent realizes a property value is invalid, it's already thrown away the other cascaded values.</p>
0 commit comments