@@ -744,7 +744,8 @@ Automatic Numbering With Counters</h2>
744
744
which are inherited through the document tree in a way similar to inherited property values.
745
745
[=Counters=] have a <dfn export for="CSS counter">name</dfn> and <dfn export for="CSS counter">creator</dfn> ,
746
746
which identify the counter,
747
- and an integer <dfn export for="CSS counter">value</dfn> .
747
+ a boolean <dfn export for="CSS counter">reversed</dfn> (false by default),
748
+ and an integer <dfn export for="CSS counter">value</dfn> (optional when the counter is <a>reversed</a> ).
748
749
They are created and manipulated with
749
750
the <dfn export>counter properties</dfn> 'counter-increment' , 'counter-set' and 'counter-reset' ,
750
751
and used with the ''counter()'' and ''counters()'' [=functional notations=] .
@@ -755,6 +756,13 @@ Automatic Numbering With Counters</h2>
755
756
A <<counter-name>> name cannot match the keyword ''counter-reset/none'' ;
756
757
such an identifier is [=invalid=] as a <<counter-name>> .
757
758
759
+ A <a>reversed</a> counter is created with the ''reversed()'' [=functional notation=] ,
760
+ which is defined as follows:
761
+
762
+ <pre>
763
+ <dfn><<reversed-counter-name>></dfn> = reversed( <<counter-name>> )
764
+ </pre>
765
+
758
766
Resolving [=counter=] values on a given element is a multi-step process:
759
767
760
768
1. Existing counters are [=inherit counters|inherited=] from previous elements.
@@ -774,12 +782,12 @@ Creating Counters: the 'counter-reset' property</h3>
774
782
775
783
<pre class="propdef">
776
784
Name : counter-reset
777
- Value : [ <<counter-name>> <<integer>>? ]+ | none
785
+ Value : [ <<counter-name>> <<integer>>? | <<reversed-counter-name>> <<integer>>? ]+ | none
778
786
Initial : none
779
787
Applies to : all elements
780
788
Inherited : no
781
789
Percentages : n/a
782
- Computed value : the keyword ''counter-reset/none'' or a list, each item an identifier paired with an integer
790
+ Computed value : the keyword ''counter-reset/none'' or a list, each item an identifier or a ''reversed()'' function paired with an integer
783
791
Animation type : by computed value type
784
792
</pre>
785
793
@@ -799,6 +807,12 @@ Creating Counters: the 'counter-reset' property</h3>
799
807
[=Instantiates=] a counter of the given <<counter-name>>
800
808
with a starting value of the given <<integer>> ,
801
809
defaulting to ''0'' .
810
+
811
+ <dt> <dfn><<reversed-counter-name>> <<integer>>?</dfn>
812
+ <dd>
813
+ [=Instantiates=] a <a>reversed</a> counter of the given <<counter-name>>
814
+ with a starting value of the given <<integer>> ,
815
+ or no starting value if not given.
802
816
</dl>
803
817
804
818
<div class='example' highlight=css>
@@ -993,7 +1007,8 @@ Creating and Inheriting Counters</h3>
993
1007
whose values are each a [=tuple=] of:
994
1008
a [=string=] (representing a counter’s [=name=] ),
995
1009
an element (representing the counter’s [=creator=] ),
996
- and an integer (representing the counter’s [=value=] ).
1010
+ a boolean (representing whether the counter is [=reversed=] ),
1011
+ and optionally an integer (representing the counter’s [=value=] ).
997
1012
The latest [=counter=] of a given name in that set
998
1013
represents the <dfn>innermost</dfn> counter of that name.
999
1014
@@ -1106,8 +1121,9 @@ Instantiating Counters</h4>
1106
1121
see [[#nested-counters]] .)
1107
1122
To <dfn lt="instantiate counter" local-lt="instantiate">instantiate a counter</dfn>
1108
1123
of a given |name|
1109
- on an |element|
1110
- with a starting |value|:
1124
+ on an |element|,
1125
+ optionally |reversed|,
1126
+ with an optional starting |value|:
1111
1127
1112
1128
1. Let |counters| be |element|’s [=CSS counters set=] .
1113
1129
@@ -1120,9 +1136,16 @@ Instantiating Counters</h4>
1120
1136
3. [=set/Append=] a new [=counter=] to |counters|
1121
1137
with name |name|,
1122
1138
originating element |element|,
1123
- and initial value |value|
1139
+ reversed being |reversed|,
1140
+ and initial value |value| (if given)
1124
1141
</div>
1125
1142
1143
+ When a [=counter=] is [=instantiated=] without an initial value,
1144
+ the user agent must dynamically calculate the initial value at layout-time
1145
+ to be the number of elements and pseudo-elements that [=instantiate=] the same counter in the same [=scope=] , plus 1.
1146
+
1147
+ Note: Only [=reversed=] counters can be instantiated without an initial value.
1148
+
1126
1149
<h3 id='counters-without-boxes'>
1127
1150
Counters in elements that do not generate boxes</h3>
1128
1151
@@ -1171,8 +1194,10 @@ The Implicit ''list-item'' Counter</h3>
1171
1194
unless the 'counter-increment' property explicitly specifies
1172
1195
a different increment for the ''list-item'' counter,
1173
1196
it must be incremented by 1 on every [=list item=] ,
1197
+ or if the counter is <a>reversed</a> ,
1198
+ it must be incremented by -1 on every [=list item=] instead,
1174
1199
at the same time that <a>counters</a> are normally incremented
1175
- (exactly as if the [=list item=] had ''list-item 1'' appended to their 'counter-increment' value,
1200
+ (exactly as if the [=list item=] had ''list-item 1'' or ''list-item -1'' appended to their 'counter-increment' value,
1176
1201
including side-effects such as possibly [=instantiating=] a new [=counter=] , etc).
1177
1202
This does not affect the [=specified value|specified=] or [=computed values=]
1178
1203
of 'counter-increment' .
@@ -1487,9 +1512,6 @@ Appendix A: Sample Style Sheet For HTML</h2>
1487
1512
this sample style sheet is provided to illustrate the CSS features
1488
1513
using familiar markup conventions.</em>
1489
1514
1490
- ISSUE: Discussion of how to support <code> ol[reversed] </code> list numbering in CSS is ongoing.
1491
- See, e.g. <a href="https://github.com/w3c/csswg-drafts/issues/4181">Issue 4181</a> .
1492
-
1493
1515
<pre>
1494
1516
/* Set up list items */
1495
1517
li {
@@ -1525,16 +1547,13 @@ Appendix A: Sample Style Sheet For HTML</h2>
1525
1547
counter-set: list-item attr(value integer, 1);
1526
1548
}
1527
1549
1528
- <!--
1529
1550
/* Handling reversed lists */
1530
1551
ol[reversed] {
1531
- counter-reset: list-item calc(attr(start integer, **magic**) + 1);
1532
- /* Where **magic** is the number of child <li> elements. */
1552
+ counter-reset: reversed(list-item);
1533
1553
}
1534
- ol[reversed] > li {
1535
- /* HTML implies ' counter-increment: list-item -1' */
1554
+ ol[reversed][start] {
1555
+ counter-reset: reversed( list-item) calc(attr(start integer) + 1);
1536
1556
}
1537
- -->
1538
1557
1539
1558
/* Box Model Rules */
1540
1559
ol, ul {
0 commit comments