Skip to content

Commit 38056ae

Browse files
committed
[css3-lists] Rewrite the scopes section, slightly tweak the previous section again.
1 parent d8b3778 commit 38056ae

2 files changed

Lines changed: 109 additions & 88 deletions

File tree

css3-lists/Overview.html

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,9 +1554,9 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
15541554
among other things, to automatically number list items in CSS.
15551555

15561556
<p> A <a href="#counter0"><i>counter</i></a> has an integer value and a <a
1557-
href="#counter-scope"><i>scope</i></a> which dictates which elements share
1558-
a given counter. The value of a <a href="#counter0"><i>counter</i></a> can
1559-
be different on different elements in the document, allowing list items to
1557+
href="#scope"><i>scope</i></a> which dictates which elements share a given
1558+
counter. The value of a <a href="#counter0"><i>counter</i></a> can be
1559+
different on different elements in the document, allowing list items to
15601560
generate successive numbers in their markers. They are created and
15611561
manipulated with the ‘<a href="#counter-increment"><code
15621562
class=property>counter-increment</code></a>’, ‘<a
@@ -1611,7 +1611,8 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
16111611

16121612
<p> The ‘<a href="#counter-reset"><code
16131613
class=property>counter-reset</code></a>’ property creates new counters,
1614-
with new associated <i>scopes</i>. Its values are defined as follows:
1614+
with new associated <a href="#scope"><i>scopes</i></a>. Its values are
1615+
defined as follows:
16151616

16161617
<dl>
16171618
<dt>none
@@ -1620,8 +1621,9 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
16201621

16211622
<dt><code>&lt;ident> &lt;integer>?</code>
16221623

1623-
<dd> The element <i title="establishes a counter">establishes one or more
1624-
new counters</i>. Each <code>&lt;ident></code> names a new counter which
1624+
<dd> The element <a href="#establishes-a-counter"><i
1625+
title="establishes a counter">establishes one or more new
1626+
counters</i></a>. Each <code>&lt;ident></code> names a new counter which
16251627
is created.
16261628
<p> If an <code>&lt;integer></code> is provided after an
16271629
<code>&lt;ident></code>, the newly established counter's value is set to
@@ -1732,7 +1734,10 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
17321734

17331735
<dd> The element alters the value of one or more counters on it. If there
17341736
is not currently a counter of the given name on the element, the element
1735-
<i>establishes a counter</i> of the given name.
1737+
<a href="#establishes-a-counter"><i>establishes a counter</i></a> of the
1738+
given name and initally sets its value to ‘<code class=css>0</code>
1739+
(though it may then immediately set or increment that value to something
1740+
different).
17361741
<p> If an <code>&lt;integer></code> is provided after an
17371742
<code>&lt;ident></code>, it sets the named counter to that integer (for
17381743
<a href="#counter-set"><code
@@ -1793,11 +1798,37 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
17931798
<h3 id=nested-counters><span class=secno>8.1. </span> Nested counters and
17941799
scope</h3>
17951800

1796-
<p> Counters are "self-nesting", in the sense that resetting a counter in a
1797-
child element automatically creates a new instance of the counter. This is
1798-
important for situations like lists in HTML, where lists can be nested
1799-
inside lists to arbitrary depth. It would be impossible to define uniquely
1800-
named counters for each level.
1801+
<p> Every <a href="#counter0"><i>counter</i></a> is associated with a <dfn
1802+
id=scope title="scope|scopes">scope</dfn>, which defines which elements in
1803+
the document share a given counter.
1804+
1805+
<p> <a href="#scope"><i>Scopes</i></a> have a name, which is the same as
1806+
their associated counter, a root element, which is the element that
1807+
establishes the counter, and a set of contained elements, which are the
1808+
elements that share the given counter. When an element <dfn
1809+
id=establishes-a-counter>establishes a counter</dfn>, it creates a counter
1810+
and scope of the given name, sets the scope's root element to the element
1811+
that establishes it, and sets the contained elements to the element and
1812+
its descendants, all following siblings of the root element up to but not
1813+
including the first sibling that establishes a counter of the same name,
1814+
and all descendants of those siblings.
1815+
1816+
<p> The value of a counter can change across its scope. Whenever an element
1817+
sets the value of a counter, the altered value is what is seen by all
1818+
elements contained in the scope that are later in document order (unless,
1819+
of course, another element between the two further alters the counter's
1820+
value).
1821+
1822+
<p> Counters are "self-nesting"; establishing a counter in an element
1823+
already contained in the scope of another counter of the same name simply
1824+
creates a new instance of the counter. This is important for situations
1825+
like lists in HTML, where lists can be nested inside lists to arbitrary
1826+
depth. It would be impossible to define uniquely named counters for each
1827+
level. As explained in a later section, the ‘<a href="#counter0"><code
1828+
class=css>counter()</code></a>’ function only uses the innermost counter
1829+
of a given name on the element, but the ‘<code
1830+
class=css>counters()</code>’ function uses all counters of a given name
1831+
that contain the element.
18011832

18021833
<div class=example>
18031834
<p> Thus, the following suffices to number nested list items. The result
@@ -1806,34 +1837,16 @@ <h3 id=nested-counters><span class=secno>8.1. </span> Nested counters and
18061837
inside</code>’ on the LI element:
18071838

18081839
<pre>
1809-
OL { counter-reset: item }
1810-
LI { display: block }
1811-
LI:before { content: counter(item) ". "; counter-increment: item }</pre>
1812-
</div>
1813-
1814-
<p> The self-nesting is based on the principle that every element or
1815-
pseudo-element that has a ‘<a href="#counter-reset"><code
1816-
class=property>counter-reset</code></a>’ for a counter X, creates a
1817-
fresh counter X, the <dfn id=counter-scope
1818-
title="scope|counter scope">scope</dfn> of which is the element or
1819-
pseudo-element, its following siblings up to but not including the first
1820-
one that resets the same counter, and all the descendants of those
1821-
elements.
1822-
1823-
<p>Additionally, if an element has a ‘<a href="#counter-set"><code
1824-
class=property>counter-set</code></a>’ or ‘<a
1825-
href="#counter-increment"><code
1826-
class=property>counter-increment</code></a>’ for a counter that is not
1827-
in scope for the element, it establishes a scope for that counter
1828-
identically to if ‘<a href="#counter-reset"><code
1829-
class=property>counter-reset</code></a>’ were used on the element to
1830-
reset the counter to ‘<code class=css>0</code>’.
1840+
ol { counter-reset: item }
1841+
li { display: block }
1842+
li::before { content: counter(item) ". "; counter-increment: item }</pre>
18311843

1832-
<p>In the example above, an OL will create a counter, and all children of
1833-
the OL will refer to that counter.
1844+
<p> In this example, an OL will create a counter, and all children of the
1845+
OL will refer to that counter.
1846+
</div>
18341847

1835-
<div class=html-example>
1836-
<p>If we denote by item[<var>n</var>] the <var>n</var><sup>th</sup>
1848+
<div class=example>
1849+
<p> If we denote by item[<var>n</var>] the <var>n</var><sup>th</sup>
18371850
instance of the "item" counter, and by "(" and ")"the beginning and end
18381851
of a scope, then the following HTML fragment will use the indicated
18391852
counters. (We assume the style sheet as given in the example above).
@@ -1859,24 +1872,9 @@ <h3 id=nested-counters><span class=secno>8.1. </span> Nested counters and
18591872
&lt;LI>item &lt;!-- increment item[4] to 1 -->
18601873
&lt;LI>item &lt;!-- increment item[4] to 2 -->
18611874
&lt;/OL> &lt;!-- ) --></pre>
1862-
</div>
1863-
1864-
<p>As explained in a later section, the ‘<a href="#counter0"><code
1865-
class=css>counter()</code></a>’ function generates a string based off of
1866-
the innermost scope of the named counter, while the ‘<code
1867-
class=css>counters()</code>’ function generates a string based on the
1868-
values of <em>all</em> the in-scope counters with a given name.
18691875

1870-
<div class=example>
1871-
<p>
1872-
1873-
<p>The following style sheet numbers nested list items as "1", "1.1",
1874-
"1.1.1", etc.
1875-
1876-
<pre>
1877-
OL { counter-reset: item }
1878-
LI { display: block }
1879-
LI:before { content: counters(item, "."); counter-increment: item }</pre>
1876+
<p class=issue> Rewrite this example as an image showing the scopes
1877+
visually.
18801878
</div>
18811879

18821880
<h3 id=counters-without-boxes><span class=secno>8.2. </span> Counters in
@@ -3692,9 +3690,6 @@ <h2 class=no-num id=index>Index</h2>
36923690
<li>counter-reset, <a href="#counter-reset"
36933691
title=counter-reset><strong>8.</strong></a>
36943692

3695-
<li>counter scope, <a href="#counter-scope"
3696-
title="counter scope"><strong>8.1.</strong></a>
3697-
36983693
<li>counter-set, <a href="#counter-set"
36993694
title=counter-set><strong>8.</strong></a>
37003695

@@ -3734,6 +3729,9 @@ <h2 class=no-num id=index>Index</h2>
37343729

37353730
<li>disc, <a href="#disc" title=disc><strong>12.</strong></a>
37363731

3732+
<li>establishes a counter, <a href="#establishes-a-counter"
3733+
title="establishes a counter"><strong>8.1.</strong></a>
3734+
37373735
<li>fallback, <a href="#descdef-fallback"
37383736
title=fallback><strong>10.6.</strong></a>
37393737

@@ -3821,7 +3819,9 @@ <h2 class=no-num id=index>Index</h2>
38213819
<li>range, <a href="#descdef-range" title=range><strong>10.5.</strong></a>
38223820

38233821

3824-
<li>scope, <a href="#counter-scope" title=scope><strong>8.1.</strong></a>
3822+
<li>scope, <a href="#scope" title=scope><strong>8.1.</strong></a>
3823+
3824+
<li>scopes, <a href="#scope" title=scopes><strong>8.1.</strong></a>
38253825

38263826
<li>square, <a href="#square" title=square><strong>12.</strong></a>
38273827

css3-lists/Overview.src.html

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,9 @@ <h2 id='counter'>
10951095
<dd>
10961096
The element alters the value of one or more counters on it.
10971097
If there is not currently a counter of the given name on the element,
1098-
the element <i>establishes a counter</i> of the given name.
1098+
the element <i>establishes a counter</i> of the given name
1099+
and initally sets its value to ''0''
1100+
(though it may then immediately set or increment that value to something different).
10991101

11001102
<p>
11011103
If an <code>&lt;integer></code> is provided after an <code>&lt;ident></code>,
@@ -1156,37 +1158,65 @@ <h3 id="nested-counters">
11561158
Nested counters and scope</h3>
11571159

11581160
<p>
1159-
Counters are "self-nesting",
1160-
in the sense that resetting a counter in a child element automatically creates a new instance of the counter.
1161+
Every <i>counter</i> is associated with a <dfn title="scope|scopes">scope</dfn>,
1162+
which defines which elements in the document share a given counter.
1163+
1164+
<p>
1165+
<i>Scopes</i> have a name,
1166+
which is the same as their associated counter,
1167+
a root element,
1168+
which is the element that establishes the counter,
1169+
and a set of contained elements,
1170+
which are the elements that share the given counter.
1171+
When an element <dfn>establishes a counter</dfn>,
1172+
it creates a counter and scope of the given name,
1173+
sets the scope's root element to the element that establishes it,
1174+
and sets the contained elements to the element and its descendants,
1175+
all following siblings of the root element up to but not including the first sibling that establishes a counter of the same name,
1176+
and all descendants of those siblings.
1177+
1178+
<p>
1179+
The value of a counter can change across its scope.
1180+
Whenever an element sets the value of a counter,
1181+
the altered value is what is seen by all elements contained in the scope
1182+
that are later in document order
1183+
(unless, of course, another element between the two further alters the counter's value).
1184+
1185+
<p>
1186+
Counters are "self-nesting";
1187+
establishing a counter in an element already contained in the scope of another counter of the same name
1188+
simply creates a new instance of the counter.
11611189
This is important for situations like lists in HTML,
11621190
where lists can be nested inside lists to arbitrary depth.
11631191
It would be impossible to define uniquely named counters for each level.
1192+
As explained in a later section,
1193+
the ''counter()'' function only uses the innermost counter of a given name on the element,
1194+
but the ''counters()'' function uses all counters of a given name that contain the element.
11641195

11651196
<div class="example">
11661197
<p>
11671198
Thus, the following suffices to number nested list items.
11681199
The result is very similar to that of setting 'display:list-item' and 'list-style: inside' on the LI element:
11691200

11701201
<pre>
1171-
OL { counter-reset: item }
1172-
LI { display: block }
1173-
LI:before { content: counter(item) ". "; counter-increment: item }</pre>
1202+
ol { counter-reset: item }
1203+
li { display: block }
1204+
li::before { content: counter(item) ". "; counter-increment: item }</pre>
1205+
1206+
<p>
1207+
In this example,
1208+
an OL will create a counter,
1209+
and all children of the OL will refer to that counter.
11741210
</div>
11751211

1176-
<p>
1177-
The self-nesting is based on the principle that every element or pseudo-element that has a 'counter-reset' for a counter X,
1178-
creates a fresh counter X,
1179-
the <dfn id="counter-scope" title="scope|counter scope">scope</dfn> of which is the element or pseudo-element,
1180-
its following siblings up to but not including the first one that resets the same counter,
1181-
and all the descendants of those elements.
11821212

1183-
<p>Additionally, if an element has a 'counter-set' or 'counter-increment' for a counter that is not in scope for the element, it establishes a scope for that counter identically to if 'counter-reset' were used on the element to reset the counter to ''0''.
1184-
1185-
<p>In the example above, an OL will create a counter, and all children of the OL will refer to that counter.
1186-
1187-
<div class="html-example">
1213+
<div class="example">
11881214

1189-
<p>If we denote by item[<var>n</var>] the <var>n</var><sup>th</sup> instance of the "item" counter, and by "(" and ")"the beginning and end of a scope, then the following HTML fragment will use the indicated counters. (We assume the style sheet as given in the example above).
1215+
<p>
1216+
If we denote by item[<var>n</var>] the <var>n</var><sup>th</sup> instance of the "item" counter,
1217+
and by "(" and ")"the beginning and end of a scope,
1218+
then the following HTML fragment will use the indicated counters.
1219+
(We assume the style sheet as given in the example above).
11901220

11911221
<pre>
11921222
&lt;OL> &lt;!-- (set item[0] to 0 -->
@@ -1209,18 +1239,9 @@ <h3 id="nested-counters">
12091239
&lt;LI>item &lt;!-- increment item[4] to 1 -->
12101240
&lt;LI>item &lt;!-- increment item[4] to 2 -->
12111241
&lt;/OL> &lt;!-- ) --></pre>
1212-
</div>
1213-
1214-
<p>As explained in a later section, the ''counter()'' function generates a string based off of the innermost scope of the named counter, while the ''counters()'' function generates a string based on the values of <em>all</em> the in-scope counters with a given name.
12151242

1216-
<div class="example"><p>
1217-
<p>The following style sheet numbers nested list items
1218-
as "1", "1.1", "1.1.1", etc.
1219-
1220-
<pre>
1221-
OL { counter-reset: item }
1222-
LI { display: block }
1223-
LI:before { content: counters(item, "."); counter-increment: item }</pre>
1243+
<p class='issue'>
1244+
Rewrite this example as an image showing the scopes visually.
12241245
</div>
12251246

12261247

0 commit comments

Comments
 (0)