1010
1111 < meta content ="CSS Lists and Counters Module Level 3 " name =dcterms.title >
1212 < meta content =text name =dcterms.type >
13- < meta content =2012-11-27 name =dcterms.issued >
13+ < meta content =2012-11-29 name =dcterms.issued >
1414 < meta content ="http://dev.w3.org/csswg/css3-lists/ " name =dcterms.creator >
1515 < meta content =W3C name =dcterms.publisher >
16- < meta content ="http://www.w3.org/TR/2012/ED-css3-lists-20121127 / "
16+ < meta content ="http://www.w3.org/TR/2012/ED-css3-lists-20121129 / "
1717 name =dcterms.identifier >
1818 < meta content ="text/html; charset=utf-8 " http-equiv =Content-Type >
1919 < link href ="http://dev.w3.org/csswg/default.css " rel =stylesheet
3636
3737 < h1 > CSS Lists and Counters Module Level 3</ h1 >
3838
39- < h2 class ="no-num no-toc " id =longstatus-date > Editor's Draft 27 November
39+ < h2 class ="no-num no-toc " id =longstatus-date > Editor's Draft 29 November
4040 2012</ h2 >
4141
4242 < dl >
4343 < dt > This version:
4444
45- < dd > <!--<a href="http://www.w3.org/TR/2012/WD-css3-lists-20121127 ">http://www.w3.org/TR/2012/WD-css3-lists-20121127 </a>-->
45+ < dd > <!--<a href="http://www.w3.org/TR/2012/WD-css3-lists-20121129 ">http://www.w3.org/TR/2012/WD-css3-lists-20121129 </a>-->
4646 < a
4747 href ="http://dev.w3.org/csswg/css3-lists/ "> http://dev.w3.org/csswg/css3-lists/</ a >
4848
@@ -1496,25 +1496,21 @@ <h3 id=marker-side><span class=secno>7.2. </span> The ‘<a
14961496 < h2 id =counter > < span class =secno > 8. </ span > Automatic Numbering With
14971497 Counters</ h2 >
14981498
1499- < p > A < dfn id =counter0 > counter</ dfn > is a special object used, among other
1500- things, to automatically number list items in CSS. They are created and
1501- manipulated with the ‘< a href ="#counter-increment "> < code
1499+ < p > A < dfn id =counter0 > counter</ dfn > is a special concept used, among other
1500+ things, to automatically number list items in CSS. Every element has a
1501+ collection of zero or more counters, which are inherited through the
1502+ document tree in a way similar to inherited property values. They are
1503+ created and manipulated with the ‘< a href ="#counter-increment "> < code
15021504 class =property > counter-increment</ code > </ a > ’, ‘< a
15031505 href ="#counter-set "> < code class =property > counter-set</ code > </ a > ’ and
15041506 ‘< a href ="#counter-reset "> < code
15051507 class =property > counter-reset</ code > </ a > ’ properties, and used with the
15061508 < a href ="#counter-function "> < code
15071509 title =counter-function > counter()</ code > </ a > and < a
15081510 href ="#counters-function "> < code
1509- title =counters-function > counters()</ code > </ a > functions. Counters have an
1510- integer value, a creator element, and possibly another counter nested
1511- inside themselves.
1512-
1513- < p > Each element has a collection of zero or more counters. Counters
1514- inherit between elements in a way similar to other CSS values, but they
1515- can inherit from previous siblings in addition to the normal behavior of
1516- inheriting from parents. Counters can also "nest" inside of each other,
1517- which makes it easier to number nested lists.
1511+ title =counters-function > counters()</ code > </ a > functions. Counters have a
1512+ name, an integer value, a creator element, and possibly another counter
1513+ nested inside themselves.
15181514
15191515 < h3 id =counter-properties > < span class =secno > 8.1. </ span > Manipulating
15201516 Counters: the ‘< a href ="#counter-increment "> < code
@@ -1724,9 +1720,10 @@ <h3 id=counter-properties><span class=secno>8.1. </span> Manipulating
17241720}</ pre >
17251721 </ div >
17261722
1727- < p > Resetting counters must be done < em > before</ em > setting counters, which
1728- must be done < em > before</ em > incrementing counters, which must be done
1729- < em > before</ em > using counters (for example, in the ‘< code
1723+ < p > Inheriting counters must be done < em > before</ em > resetting counters,
1724+ which must be done < em > before</ em > setting counters, which must be done
1725+ < em > before</ em > incrementing counters, which must be done < em > before</ em >
1726+ using counters (for example, in the ‘< code
17301727 class =property > content</ code > ’ property).
17311728
17321729 < div class =note >
@@ -1756,15 +1753,78 @@ <h3 id=creating-counters><span class=secno>8.2. </span> Creating and
17561753 Inheriting Counters</ h3 >
17571754
17581755 < p > Every element has a (possibly empty) set of counters. Like many other
1759- CSS values, an element can inherit counters from another element. Unlike
1760- many other CSS values, elements can inherit counters from their previous
1761- sibling as well as their parent.
1756+ CSS values, an element can inherit counters from another element. However,
1757+ unlike other CSS values, the method that counters are inherited is
1758+ somewhat complex. A counter and its value are inherited
1759+ < em > separately</ em > , possibly from different elements.
1760+
1761+ < p > If an element has a previous sibling, it must inherit all of the
1762+ sibling's counters. Otherwise, if the element has a parent, it must
1763+ inherit all of the parent's counters. Otherwise, the element must have an
1764+ empty set of counters.
1765+
1766+ < p > The element then inherits counter < em > values</ em > from the immediately
1767+ preceding element < strong > in document order</ strong > . This must be done by
1768+ examining the set of counters that the immediately preceding element has,
1769+ and, for every counter that exists in both the element's set and the
1770+ preceding element's set, giving the element's counter the same value. (If
1771+ an element is the first element in the document, and thus has no
1772+ immediately preceding element, it also doesn't have a parent or a previous
1773+ sibling, and thus no counters to begin with.)
1774+
1775+ < div class =example id =counter-inheritance-example >
1776+ < p > Take the following code as an example:
1777+
1778+ < pre >
1779+ <ul style='counter-reset: example 0;'>
1780+ < b
1781+ class =foo > <li id='foo' style='counter-increment: example;'> </ b >
1782+ foo
1783+ < b
1784+ class =bar > <div id='bar' style='counter-increment: example;'> bar</div> </ b >
1785+ </li>
1786+ < b
1787+ class =baz > <li id='baz'> </ b >
1788+ baz
1789+ </li>
1790+ </ul> </ pre >
1791+
1792+ < p > Recall that "in document order" turns a document tree into an ordered
1793+ list, where an element comes before its children, and its children come
1794+ before its next sibling. In other words, for a language like HTML, its
1795+ the order in which the parser encounters start tags as it reads the
1796+ document.
1797+
1798+ < p > In here, the < code > <ul> </ code > element establishes a new counter
1799+ named "example", and sets its value to 0. The < b class =foo > "foo"</ b >
1800+ element, being the first child of the < code > <ul> </ code > , inherits this
1801+ counter. Its parent is also its immediately preceding element in document
1802+ order, so it inherits the value 0 with it, and then immediately
1803+ increments the value to 1.
1804+
1805+ < p > The same happens with the < b class =bar > "bar"</ b > element. It inherits
1806+ the "example" counter from < b class =foo > "foo"</ b > , and inherits the value
1807+ 1 from it as well and increments it to 2.
1808+
1809+ < p > However, the < b class =baz > "baz"</ b > element is a bit different. It
1810+ inherits the "example" counter from the < b class =foo > "foo"</ b > element,
1811+ its previous sibling. However, rather than inheriting the value 1 from < b
1812+ class =foo > "foo"</ b > along with the counter, in inherits the value 2 from
1813+ < b class =bar > "bar"</ b > , the previous element in document order.
1814+
1815+ < p > This behavior allows a single counter to be used throughout a
1816+ document, continuously incrementing, without the author having to worry
1817+ about the nested structure of their document.
1818+ </ div >
17621819
1763- < p > If an element has a previous sibling, it inherits all of the sibling's
1764- counters (both those the sibling inherited, and ones the sibling created).
1765- Otherwise, if an element has a parent, it inherits all of the parent's
1766- counters. Otherwise, the element starts with an empty set of counters.
1820+ < head >
1821+ < style >
1822+ # counter-inheritance-example b .foo { color : hsl (0 , 80% , 40% ); }
1823+ # counter-inheritance-example b .bar { color : hsl (120 , 80% , 30% ); }
1824+ # counter-inheritance-example b .baz { color : hsl (240 , 80% , 50% ); }
1825+ </ style >
17671826
1827+ < body >
17681828 < p > Elements can create additional counters on themselves, which can then
17691829 be passed onto siblings or children. To < dfn
17701830 id =create-a-new-counter > create a new counter</ dfn > , specify an element
@@ -1775,8 +1835,8 @@ <h3 id=creating-counters><span class=secno>8.2. </span> Creating and
17751835 < li > If no counters of that name exist on the element, create a new
17761836 counter with that name on the element.
17771837
1778- < li > Otherwise, if a counter of the name exists on the element, and it was
1779- created by a preceding sibling, replace the innermost counter of that
1838+ < li > Otherwise, if a counter of that name exists on the element, and it
1839+ was created by a preceding sibling, replace the innermost counter of that
17801840 name on the element with a newly-created counter with that name.
17811841
17821842 < li > Otherwise, create a new counter with that name and nest it inside of
0 commit comments