@@ -820,7 +820,7 @@ Manipulating Counter Values: the 'counter-increment' and 'counter-set' propertie
820
820
but only the last set value will take effect.
821
821
822
822
<h3 id='nested-counters'>
823
- Nested Counters</h3>
823
+ Nested Counters and Scope </h3>
824
824
825
825
Counters are “self-nesting”;
826
826
[=instantiating=] a new counter on an element
@@ -834,6 +834,16 @@ Nested Counters</h3>
834
834
The ''counter()'' function only retrieves the innermost counter of a given name on the element,
835
835
whereas the ''counters()'' function uses all counters of a given name that contain the element.
836
836
837
+ The <dfn lt="counter scope" local-lt="scope">scope</dfn> of a [=counter=] therefore
838
+ starts at the first element in the document that [=instantiates=] that counter
839
+ and includes the element’s descendants and its following siblings with their descendants.
840
+ However, it does not include any elements in the scope of a counter with the same name
841
+ created by a 'counter-reset' on a later sibling of the element,
842
+ allowing such explicit counter instantiations
843
+ to obscure those earlier siblings.
844
+
845
+ See [[#creating-counters]] for the exact rules governing the scope of counters and their values.
846
+
837
847
<div class="example" id='counter-nesting-example'>
838
848
The following code numbers nested list items.
839
849
The result is very similar to that of setting ''display:list-item'' and ''list-style: inside'' on the LI element:
@@ -895,15 +905,17 @@ Nested Counters</h3>
895
905
Creating and Inheriting Counters</h3>
896
906
897
907
Each element or pseudo-element in a document has
898
- a (possibly empty) set of [=counters=] associated to the element,
908
+ a (possibly empty) set of [=counters=] in the [=scope=] of that element,
899
909
either through inheritance from another element
900
910
or through instantiation on the element directly.
901
911
These counters are represented as a <dfn>CSS counters set</dfn> ,
902
912
which is a [=/set=]
903
913
whose values are [=tuples=] of:
904
914
a [=string=] (representing a counter’s name),
905
915
an element (representing the counter’s originating element),
906
- and an integer (representing the counter’s value).
916
+ and an integer (representing the counter’s value),
917
+ the latest one of a given name
918
+ representing the “innermost” counter of that name.
907
919
908
920
<div algorithm>
909
921
An element [=inherit counters|inherits=] its initial set of counters
0 commit comments