Skip to content

Commit 9d63557

Browse files
committed
[css-lists-3] Rephrasing 'implicit list-item counter' 2nd pass. #4168
1 parent 6bdbccf commit 9d63557

File tree

1 file changed

+52
-33
lines changed

1 file changed

+52
-33
lines changed

css-lists-3/Overview.bs

+52-33
Original file line numberDiff line numberDiff line change
@@ -1066,34 +1066,49 @@ The Implicit ''list-item'' Counter</h3>
10661066
In addition to any explicitly defined [=counters=]
10671067
that authors write in their styles,
10681068
[=list items=] automatically increment
1069-
a special <dfn value for="counter-increment, counter-set, counter-reset, counter(), counters()">list-item</dfn> <a>counter</a>.
1070-
1071-
By default, the ''list-item'' counter
1072-
must be incremented by 1 on every [=list item=],
1073-
exactly as if the [=list item=] had ''list-item 1'' appended to their 'counter-increment' value
1074-
(including side-effects such as possibly [=instantiating=] a new [=counter=], etc).
1075-
This happens at the same time as when [=counters=] are normally incremented,
1076-
and does not affect the [=specified value|specified=] or [=computed value=] of 'counter-increment'.
1077-
1078-
This automatic increment <strong>does not</strong> happen
1079-
if the [=list item’s=] 'counter-increment'
1080-
explicitly mentions the ''list-item'' counter:
1081-
''li { counter-increment: list-item 2; }''
1082-
will increment ''list-item'' by 2,
1083-
not by 3 as would happen if you additionally appended ''list-item 1'' to that.
1084-
1085-
Host languages can additionally define more complex behavior
1086-
based on their own semantics.
1087-
For example, HTML lists can have a <{ol/reversed}> attribute,
1088-
which causes the ''list-item'' counter to count <em>down</em> instead on the list items belonging to that element.
1089-
1090-
Note: Per [[#text-markers]],
1091-
the ''list-item'' counter
1092-
is used to generate the [=marker string=] for [=list items=];
1093-
in other words,
1094-
it's the counter used when you set 'list-style-type'
1095-
to something that can show a counter's value,
1096-
like ''decimal''.
1069+
a special <dfn value for="counter-increment, counter-set, counter-reset, counter(), counters()">list-item</dfn> <a>counter</a>,
1070+
which is used when generating the default [=marker string=] on [=list items=]
1071+
(see 'list-style-type').
1072+
1073+
Specifically,
1074+
unless the 'counter-increment' property explicitly specifies
1075+
a different increment for the ''list-item'' counter,
1076+
it must be incremented by 1 on every [=list item=],
1077+
at the same time that <a>counters</a> are normally incremented
1078+
(exactly as if the [=list item=] had ''list-item 1'' appended to their 'counter-increment' value,
1079+
including side-effects such as possibly [=instantiating=] a new [=counter=], etc).
1080+
This does not affect the [=specified value|specified=] or [=computed values=]
1081+
of 'counter-increment'.
1082+
1083+
<div class="example">
1084+
Because each [=list item=] automatically increments
1085+
the ''counter-increment/list-item'' counter by 1,
1086+
consecutive [=list items=] with a numeric 'list-style-type'
1087+
will be consecutively numbered by default--
1088+
even if the author sets 'counter-increment' to another value
1089+
such as ''counter-increment: itemnumber'' or even ''counter-increment/none''.
1090+
This protects the automatic ''counter-increment/list-item'' counter
1091+
from inadvertently being overridden
1092+
by declarations intended to address other counters.
1093+
1094+
However, since the automatic ''counter-increment/list-item'' increment
1095+
<em>does not</em> happen
1096+
if the [=list item’s=] 'counter-increment'
1097+
explicitly mentions the ''list-item'' counter,
1098+
''li { counter-increment: list-item 2; }''
1099+
will increment ''list-item'' by 2 as specified,
1100+
not by 3 as would happen
1101+
if ''list-item 1'' were unconditionally appended.
1102+
1103+
This also allows to turn off the automatic ''list-item'' counter increment,
1104+
by overriding it explicitly, e.g. ''counter-increment: list-item 0;''.
1105+
</div>
1106+
1107+
In all other respects, the ''counter-increment/list-item'' [=counter=]
1108+
behaves like any other [=counter=]
1109+
and can be used and manipulated by authors
1110+
to adjust [=list item=] styling
1111+
or for other purposes.
10971112

10981113
<div class="example">
10991114

@@ -1113,11 +1128,13 @@ The Implicit ''list-item'' Counter</h3>
11131128
</pre>
11141129
</div>
11151130

1116-
Note: This means that ''counter-increment: none''
1117-
still lets the ''list-item'' counter increment on [=list items=].
1118-
If one wants to explicitly turn off the ''list-item'' counter as well
1119-
(perhaps because they are doing something more complicated with it themselves),
1120-
one must write ''counter-increment: list-item 0;''.
1131+
UAs and host languages should ensure
1132+
that the ''counter-increment/list-item'' counter values
1133+
by default
1134+
reflect the underlying numeric value dictated by host language semantics
1135+
when setting up list item styling
1136+
in their UA style sheet and presentational hint style mappings.
1137+
See, e.g. [[#ua-stylesheet]].
11211138

11221139
<!--
11231140
See old <a href="https://github.com/w3c/csswg-drafts/issues/2464#issuecomment-375492907">WG discussions</a>
@@ -1367,6 +1384,8 @@ Outputting Counters: the ''counter()'' and ''counters()'' functions</h3>
13671384
<h2 id='ua-stylesheet'>
13681385
Appendix A: Sample Style Sheet For HTML</h2>
13691386

1387+
Issue: Need to check this section for errors.
1388+
13701389
<em>This section is informative, not normative.
13711390
HTML itself defines the actual default properties that apply to HTML lists.</em>
13721391

0 commit comments

Comments
 (0)