Skip to content

Commit 15ec9a9

Browse files
committed
Editorial revision of the 'using variables' chapter.
1 parent 564b3a0 commit 15ec9a9

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

css-variables/Overview.html

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,22 +448,28 @@ <h2 id=defining-variables><span class=secno>2. </span> Defining Variables
448448
<h2 id=using-variables><span class=secno>3. </span> Using Variables: the
449449
data() function</h2>
450450

451-
<p>The value of a <a href="#data-property"><i>data property</i></a> may be
452-
substituted into any other property (including other data properties) by
453-
referencing it with the &lsquo;<code class=css>data()</code>&rsquo;
454-
function, otherwise known as a <a
455-
href="#type-variable"><i>variable</i></a>. The syntax of the &lsquo;<code
456-
class=css>data()</code>&rsquo; function is:
451+
<p>A <dfn id=variable>variable</dfn> allows the value of a <a
452+
href="#data-property"><i>data property</i></a> on an element to be
453+
substituted into another property on the element. Variables are used with
454+
the &lsquo;<code class=css>data()</code>&rsquo; function, taking the name
455+
of a variable and returning the value of the associated data property. The
456+
syntax of the &lsquo;<code class=css>data()</code>&rsquo; function is:
457457

458458
<pre><dfn id=type-variable
459459
title="variable|variables">&lt;variable></dfn> = data( IDENT )</pre>
460460

461461
<p>The &lsquo;<code class=css>data()</code>&rsquo; function references the
462-
<a href="#data-property"><i>data property</i></a> named when the "data-"
463-
prefix is added to the argument to the function.
464-
465-
<p class=issue>Um, can you use a variable variable? Is &lsquo;<code
466-
class=css>data(data(foo))</code>&rsquo; valid?
462+
<a href="#data-property"><i>data property</i></a> with the name obtained
463+
by prepending "data-" to the function's argument. <span class=note>Note
464+
that all possible <a href="#data-property"><i>data properties</i></a>
465+
exist; if one with the given name has not yet been defined in the
466+
document, it simply takes its initial value.</span> When a property
467+
resolves its computed value, a &lsquo;<code class=css>data()</code>&rsquo;
468+
function is replaced by the value of the referenced <a
469+
href="#data-property"><i>data property</i></a>.
470+
471+
<p class=issue>What about variable variables? Should &lsquo;<code
472+
class=css>data(data(foo))</code>&rsquo; be valid? (Probably not.)
467473

468474
<p>A variable can be used anywhere a value is expected in CSS. Variables
469475
can not be used as property names, selectors, or anything else besides
@@ -857,6 +863,7 @@ <h2 class=no-num id=index>Index</h2>
857863
</ul>
858864

859865
<li>variable, <a href="#type-variable"
866+
title=variable><strong>3.</strong></a>, <a href="#variable"
860867
title=variable><strong>3.</strong></a>
861868

862869
<li>variables, <a href="#type-variable"

css-variables/Overview.src.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,13 @@ <h2 id="defining-variables">
210210
<h2 id='using-variables'>
211211
Using Variables: the data() function</h2>
212212

213-
<p>The value of a <i>data property</i> may be substituted into any other property (including other data properties) by referencing it with the ''data()'' function, otherwise known as a <i>variable</i>. The syntax of the ''data()'' function is:</p>
213+
<p>A <dfn>variable</dfn> allows the value of a <i>data property</i> on an element to be substituted into another property on the element. Variables are used with the ''data()'' function, taking the name of a variable and returning the value of the associated data property. The syntax of the ''data()'' function is:</p>
214214

215215
<pre><dfn id='type-variable' title="variable|variables">&lt;variable></dfn> = data( IDENT )</pre>
216216

217-
<p>The ''data()'' function references the <i>data property</i> named when the "data-" prefix is added to the argument to the function.</p>
217+
<p>The ''data()'' function references the <i>data property</i> with the name obtained by prepending "data-" to the function's argument. <span class='note'>Note that all possible <i>data properties</i> exist; if one with the given name has not yet been defined in the document, it simply takes its initial value.</span> When a property resolves its computed value, a ''data()'' function is replaced by the value of the referenced <i>data property</i>.</p>
218218

219-
<p class='issue'>Um, can you use a variable variable? Is ''data(data(foo))'' valid?</p>
219+
<p class='issue'>What about variable variables? Should ''data(data(foo))'' be valid? (Probably not.)</p>
220220

221221
<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>
222222

0 commit comments

Comments
 (0)