Skip to content

Commit d8b3778

Browse files
committed
[css3-lists] Rewrite and reorganize the 'counter-*' section.
1 parent b6508ca commit d8b3778

2 files changed

Lines changed: 190 additions & 93 deletions

File tree

css3-lists/Overview.html

Lines changed: 102 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525

2626
<h1>CSS Lists and Counters Module Level 3</h1>
2727

28-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 24 August 2012</h2>
28+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 25 August 2012</h2>
2929

3030
<dl>
3131
<dt>This version:
3232

33-
<dd><!--<a href="http://www.w3.org/TR/2012/WD-css3-lists-20120824">http://www.w3.org/TR/2012/WD-css3-lists-20120824</a>-->
33+
<dd><!--<a href="http://www.w3.org/TR/2012/WD-css3-lists-20120825">http://www.w3.org/TR/2012/WD-css3-lists-20120825</a>-->
3434
<a
3535
href="http://dev.w3.org/csswg/css3-lists/">http://dev.w3.org/csswg/css3-lists/</a>
3636

@@ -354,12 +354,13 @@ <h2 id=declaring-a-list-item><span class=secno>2. </span> Declaring a List
354354
class=css>::marker</code>’ pseudo-elements; no other elements do.
355355

356356
<p> Additionally, <a href="#list-item"><i>list items</i></a> automatically
357-
increment the special ‘<code class=css>list-item</code>
358-
<i>counter</i>. Unless the ‘<a href="#counter-increment"><code
357+
increment the special ‘<code class=css>list-item</code><a
358+
href="#counter0"><i>counter</i></a>. Unless the ‘<a
359+
href="#counter-increment"><code
359360
class=property>counter-increment</code></a>’ property manually specifies
360-
a different increment for the ‘<code class=css>list-item</code>
361-
<i>counter</i>, it must be incremented by 1 on every <a
362-
href="#list-item"><i>list item</i></a>, at the same time that
361+
a different increment for the ‘<code class=css>list-item</code> <a
362+
href="#counter0"><i>counter</i></a>, it must be incremented by 1 on every
363+
<a href="#list-item"><i>list item</i></a>, at the same time that
363364
<i>counters</i> are normally incremented. (This has no effect on the
364365
values of the ‘<code class=css>counter-*</code>’ properties.)
365366

@@ -1549,27 +1550,33 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
15491550
<a href="#counter-reset"><code
15501551
class=property>counter-reset</code></a>’ properties</h2>
15511552

1552-
<p>Automatic numbering in CSS2 is controlled with three properties: ‘<a
1553-
href="#counter-increment"><code
1553+
<p> A <dfn id=counter0>counter</dfn> is a special numeric object used,
1554+
among other things, to automatically number list items in CSS.
1555+
1556+
<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
1560+
generate successive numbers in their markers. They are created and
1561+
manipulated with the ‘<a href="#counter-increment"><code
15541562
class=property>counter-increment</code></a>’, ‘<a
15551563
href="#counter-set"><code class=property>counter-set</code></a>’ and
15561564
<a href="#counter-reset"><code
1557-
class=property>counter-reset</code></a>’. The <dfn id=counters
1558-
title="list counter">counters</dfn> defined by these properties are used
1559-
with the ‘<code class=css>counter()</code>’ and ‘<code
1560-
class=css>counters()</code>’ functions.
1565+
class=property>counter-reset</code></a>’ properties, and used with the
1566+
<a href="#counter0"><code class=css>counter()</code></a>’ and
1567+
<code class=css>counters()</code>’ functions.
15611568

15621569
<table class=propdef>
15631570
<tbody>
15641571
<tr>
15651572
<th>Name:
15661573

1567-
<td><dfn id=counter-increment>counter-increment</dfn>
1574+
<td><dfn id=counter-reset>counter-reset</dfn>
15681575

15691576
<tr>
15701577
<th>Value:
15711578

1572-
<td>[ &lt;identifier> &lt;integer>? ]+ | none
1579+
<td>[ &lt;ident> &lt;integer>? ]+ | none
15731580

15741581
<tr>
15751582
<th>Initial:
@@ -1602,6 +1609,26 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
16021609
<td>specified value
16031610
</table>
16041611

1612+
<p> The ‘<a href="#counter-reset"><code
1613+
class=property>counter-reset</code></a>’ property creates new counters,
1614+
with new associated <i>scopes</i>. Its values are defined as follows:
1615+
1616+
<dl>
1617+
<dt>none
1618+
1619+
<dd> This element does not establish any new counters.
1620+
1621+
<dt><code>&lt;ident> &lt;integer>?</code>
1622+
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
1625+
is created.
1626+
<p> If an <code>&lt;integer></code> is provided after an
1627+
<code>&lt;ident></code>, the newly established counter's value is set to
1628+
that integer.. Otherwise, the starting value of the new counter is
1629+
<code class=css>0</code>’.
1630+
</dl>
1631+
16051632
<table class=propdef>
16061633
<tbody>
16071634
<tr>
@@ -1612,7 +1639,7 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
16121639
<tr>
16131640
<th>Value:
16141641

1615-
<td>[ &lt;identifier> &lt;integer>? ]+ | none
1642+
<td>[ &lt;ident> &lt;integer>? ]+ | none
16161643

16171644
<tr>
16181645
<th>Initial:
@@ -1650,12 +1677,12 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
16501677
<tr>
16511678
<th>Name:
16521679

1653-
<td><dfn id=counter-reset>counter-reset</dfn>
1680+
<td><dfn id=counter-increment>counter-increment</dfn>
16541681

16551682
<tr>
16561683
<th>Value:
16571684

1658-
<td>[ &lt;identifier> &lt;integer>? ]+ | none
1685+
<td>[ &lt;ident> &lt;integer>? ]+ | none
16591686

16601687
<tr>
16611688
<th>Initial:
@@ -1688,37 +1715,36 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
16881715
<td>specified value
16891716
</table>
16901717

1691-
<p>The ‘<a href="#counter-increment"><code
1692-
class=property>counter-increment</code></a>’ property accepts one or
1693-
more names of counters (identifiers), each one optionally followed by an
1694-
integer. The integer indicates by how much the counter is incremented for
1695-
the element it's set on. The default increment is ‘<code
1696-
class=css>1</code>’.
1697-
1698-
<p>The ‘<a href="#counter-set"><code
1718+
<p> The ‘<a href="#counter-set"><code
16991719
class=property>counter-set</code></a>’ and ‘<a
1700-
href="#counter-reset"><code class=property>counter-reset</code></a>
1701-
properties also contains a list of one or more names of counters, each one
1702-
optionally followed by an integer. The integer gives the value that the
1703-
counter is set to on the element it's set on. The default is ‘<code
1704-
class=css>0</code>’.
1705-
1706-
<p>On all of these properties, a value of ‘<a
1707-
href="#list-style-type-none"><code class=property>none</code></a>’ means
1708-
that no counters are incremented, set, or reset, respectively. Counter
1709-
names must not be ‘<code class=property>initial</code>’, ‘<code
1710-
class=property>inherit</code>’, or ‘<a
1711-
href="#list-style-type-none"><code class=property>none</code></a>’;
1712-
using one of these keywords as a counter name makes the property invalid.
1713-
1714-
<p><a href="#counter-reset"><code
1715-
class=property>counter-reset</code></a>’ always establishes a new <a
1716-
href="#counter-scope"><i>counter scope</i></a> on the element it's set on.
1717-
<a href="#counter-increment"><code
1718-
class=property>counter-increment</code></a>’ and ‘<a
1719-
href="#counter-set"><code class=property>counter-set</code></a>
1720-
sometimes establish a new <a href="#counter-scope"><i>counter
1721-
scope</i></a> on the element they're set on.
1720+
href="#counter-increment"><code
1721+
class=property>counter-increment</code></a>’ properties manipulate the
1722+
value of existing counters. They only create new counters if there is no
1723+
counter of the given name on the element yet. Their values are defined as
1724+
follows:
1725+
1726+
<dl>
1727+
<dt>none
1728+
1729+
<dd> This element does not alter the value of any counters.
1730+
1731+
<dt><code>&lt;ident> &lt;integer>?</code>
1732+
1733+
<dd> The element alters the value of one or more counters on it. If there
1734+
is not currently a counter of the given name on the element, the element
1735+
<i>establishes a counter</i> of the given name.
1736+
<p> If an <code>&lt;integer></code> is provided after an
1737+
<code>&lt;ident></code>, it sets the named counter to that integer (for
1738+
<a href="#counter-set"><code
1739+
class=property>counter-set</code></a>’) or increments the value of the
1740+
named counter by that integer (for ‘<a href="#counter-increment"><code
1741+
class=property>counter-increment</code></a>’). Otherwise, the
1742+
counter's value is set to ‘<code class=css>0</code>’ (for ‘<a
1743+
href="#counter-set"><code class=property>counter-set</code></a>’) or
1744+
incremented by ‘<code class=css>1</code>’ (for ‘<a
1745+
href="#counter-increment"><code
1746+
class=property>counter-increment</code></a>’).
1747+
</dl>
17221748

17231749
<div class=example>
17241750
<p>This example shows a way to number chapters and sections with "Chapter
@@ -1736,13 +1762,13 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
17361762
}</pre>
17371763
</div>
17381764

1739-
<p>Resetting a counter is done <em>before</em> setting a counter, which is
1740-
done <em>before</em> incrementing a counter, which is done <em>before</em>
1741-
using a counter (for example, in the ‘<code
1765+
<p> Resetting a counter must be done <em>before</em> setting a counter,
1766+
which must be done <em>before</em> incrementing a counter, which must be
1767+
done <em>before</em> using a counter (for example, in the ‘<code
17421768
class=property>content</code>’ property).
17431769

17441770
<div class=note>
1745-
<p>The counter properties follow the cascading rules as normal. Thus, due
1771+
<p> The counter properties follow the cascading rules as normal. Thus, due
17461772
to cascading, the following style sheet:
17471773

17481774
<div class=example>
@@ -1751,14 +1777,14 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
17511777
H1 { counter-reset: imagenum 99 }</pre>
17521778
</div>
17531779

1754-
<p>will only reset ‘<code class=property>imagenum</code>’. To reset
1780+
<p> will only reset ‘<code class=property>imagenum</code>’. To reset
17551781
both counters, they have to be specified together:
17561782

17571783
<div class=example>
17581784
<pre>H1 { counter-reset: section -1 imagenum 99 }</pre>
17591785
</div>
17601786

1761-
<p>The same principles apply to the ‘<a href="#counter-set"><code
1787+
<p> The same principles apply to the ‘<a href="#counter-set"><code
17621788
class=property>counter-set</code></a>’ and ‘<a
17631789
href="#counter-increment"><code
17641790
class=property>counter-increment</code></a>’ properties.
@@ -1767,15 +1793,15 @@ <h2 id=counter><span class=secno>8. </span> Automatic Counters and
17671793
<h3 id=nested-counters><span class=secno>8.1. </span> Nested counters and
17681794
scope</h3>
17691795

1770-
<p>Counters are "self-nesting", in the sense that resetting a counter in a
1796+
<p> Counters are "self-nesting", in the sense that resetting a counter in a
17711797
child element automatically creates a new instance of the counter. This is
17721798
important for situations like lists in HTML, where lists can be nested
17731799
inside lists to arbitrary depth. It would be impossible to define uniquely
17741800
named counters for each level.
17751801

17761802
<div class=example>
1777-
<p>Thus, the following suffices to number nested list items. The result is
1778-
very similar to that of setting ‘<code
1803+
<p> Thus, the following suffices to number nested list items. The result
1804+
is very similar to that of setting ‘<code
17791805
class=css>display:list-item</code>’ and ‘<code class=css>list-style:
17801806
inside</code>’ on the LI element:
17811807

@@ -1785,7 +1811,7 @@ <h3 id=nested-counters><span class=secno>8.1. </span> Nested counters and
17851811
LI:before { content: counter(item) ". "; counter-increment: item }</pre>
17861812
</div>
17871813

1788-
<p>The self-nesting is based on the principle that every element or
1814+
<p> The self-nesting is based on the principle that every element or
17891815
pseudo-element that has a ‘<a href="#counter-reset"><code
17901816
class=property>counter-reset</code></a>’ for a counter X, creates a
17911817
fresh counter X, the <dfn id=counter-scope
@@ -1835,9 +1861,9 @@ <h3 id=nested-counters><span class=secno>8.1. </span> Nested counters and
18351861
&lt;/OL> &lt;!-- ) --></pre>
18361862
</div>
18371863

1838-
<p>As explained in a later section, the ‘<code
1839-
class=css>counter()</code>’ function generates a string based off of the
1840-
innermost scope of the named counter, while the ‘<code
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
18411867
class=css>counters()</code>’ function generates a string based on the
18421868
values of <em>all</em> the in-scope counters with a given name.
18431869

@@ -1879,12 +1905,12 @@ <h3 id=counters-without-boxes><span class=secno>8.2. </span> Counters in
18791905
so do not apply here.
18801906

18811907
<h2 id=counter-function><span class=secno>9. </span> Printing Counters: the
1882-
<code class=css>counter()</code>’ and<code
1883-
class=css>counters()</code>’ functions</h2>
1908+
<a href="#counter0"><code class=css>counter()</code></a>’ and
1909+
<code class=css>counters()</code>’ functions</h2>
18841910

18851911
<p>Counters have no visible effect by themselves, but their values can be
1886-
used in the ‘<code class=css>counter()</code>’ and ‘<code
1887-
class=css>counters()</code>’ functions to generate counter
1912+
used in the ‘<a href="#counter0"><code class=css>counter()</code></a>
1913+
and ‘<code class=css>counters()</code>’ functions to generate counter
18881914
representations. This happens automatically in the default contents of
18891915
<code class=css>::marker</code>’ pseudo-elements, but can be used by
18901916
an author anywhere that accepts a string. Their syntax is:
@@ -1906,10 +1932,10 @@ <h2 id=counter-function><span class=secno>9. </span> Printing Counters: the
19061932
named counter's value using the function's ‘<code
19071933
class=css>&lt;counter-style></code>’. If there are multiple counters of
19081934
that name in scope, the one whose scoping element is closest in
1909-
document-order to the element on which ‘<code
1910-
class=css>counter()</code>’ appears is used. If there are no counters of
1911-
that name in scope, use the value ‘<code class=css>0</code>’ to
1912-
generate the counter representation. If ‘<a
1935+
document-order to the element on which ‘<a href="#counter0"><code
1936+
class=css>counter()</code></a>’ appears is used. If there are no
1937+
counters of that name in scope, use the value ‘<code
1938+
class=css>0</code>’ to generate the counter representation. If ‘<a
19131939
href="#list-style-type-none"><code class=css>none</code></a>’ is
19141940
provided as the second argument, the ‘<a
19151941
href="#ltcounter-function"><code
@@ -2056,7 +2082,8 @@ <h2 id=counter-style><span class=secno>10. </span> Defining Custom Counter
20562082
this in an open-ended manner, by allowing the author to define their own
20572083
counter styles. These styles can then be used in the ‘<a
20582084
href="#list-style-type"><code class=property>list-style-type</code></a>
2059-
property or in the ‘<code class=css>counter()</code>’ and ‘<code
2085+
property or in the ‘<a href="#counter0"><code
2086+
class=css>counter()</code></a>’ and ‘<code
20602087
class=css>counters()</code>’ functions.
20612088

20622089
<p>A <dfn id=counter-style0>counter style</dfn> defines how to construct
@@ -3459,7 +3486,7 @@ <h2 class=no-num id=property-index>Property index</h2>
34593486
<tr>
34603487
<th><a class=property href="#counter-increment">counter-increment</a>
34613488

3462-
<td>[ &lt;identifier> &lt;integer>? ]+ | none
3489+
<td>[ &lt;ident> &lt;integer>? ]+ | none
34633490

34643491
<td>none
34653492

@@ -3474,7 +3501,7 @@ <h2 class=no-num id=property-index>Property index</h2>
34743501
<tr>
34753502
<th><a class=property href="#counter-reset">counter-reset</a>
34763503

3477-
<td>[ &lt;identifier> &lt;integer>? ]+ | none
3504+
<td>[ &lt;ident> &lt;integer>? ]+ | none
34783505

34793506
<td>none
34803507

@@ -3489,7 +3516,7 @@ <h2 class=no-num id=property-index>Property index</h2>
34893516
<tr>
34903517
<th><a class=property href="#counter-set">counter-set</a>
34913518

3492-
<td>[ &lt;identifier> &lt;integer>? ]+ | none
3519+
<td>[ &lt;ident> &lt;integer>? ]+ | none
34933520

34943521
<td>none
34953522

@@ -3636,6 +3663,8 @@ <h2 class=no-num id=index>Index</h2>
36363663

36373664
<li>circle, <a href="#circle" title=circle><strong>12.</strong></a>
36383665

3666+
<li>counter, <a href="#counter0" title=counter><strong>8.</strong></a>
3667+
36393668
<li>counter-algorithm, <a href="#algorithm"
36403669
title=counter-algorithm><strong>10.</strong></a>
36413670

@@ -3733,9 +3762,6 @@ <h2 class=no-num id=index>Index</h2>
37333762
<li>inside, <a href="#list-style-position-inside"
37343763
title=inside><strong>4.</strong></a>
37353764

3736-
<li>list counter, <a href="#counters"
3737-
title="list counter"><strong>8.</strong></a>
3738-
37393765
<li>list item, <a href="#list-item"
37403766
title="list item"><strong>2.</strong></a>
37413767

0 commit comments

Comments
 (0)