Skip to content

Commit 848b8c6

Browse files
committed
[css-lists-3] Rewrite counter() section to be more author-friendly, drop 'none' value to match CSS2 w3c#4163
1 parent cda64b3 commit 848b8c6

File tree

1 file changed

+34
-52
lines changed

1 file changed

+34
-52
lines changed

css-lists-3/Overview.bs

+34-52
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ Nested Counters and Scope</h3>
815815
This is important for situations like lists in HTML,
816816
where lists can be nested inside lists to arbitrary depth:
817817
it would be impossible to define uniquely named counters for each level.
818-
The ''counter()'' function only retrieves the innermost counter of a given name on the element,
818+
The ''counter()'' function only retrieves the [=innermost=] counter of a given name on the element,
819819
whereas the ''counters()'' function uses all counters of a given name that contain the element.
820820

821821
The <dfn lt="counter scope" local-lt="scope">scope</dfn> of a [=counter=] therefore
@@ -899,7 +899,7 @@ Creating and Inheriting Counters</h3>
899899
an element (representing the counter’s originating element),
900900
and an integer (representing the counter’s value).
901901
The latest [=counter=] of a given name in that set
902-
represents the innermost counter of that name.
902+
represents the <dfn>innermost</dfn> counter of that name.
903903

904904
<h4 id="inheriting-counters">
905905
Inheriting Counters</h4>
@@ -1147,34 +1147,47 @@ The Implicit ''list-item'' Counter</h3>
11471147
<h3 id='counter-functions'>
11481148
Outputting Counters: the ''counter()'' and ''counters()'' functions</h3>
11491149

1150-
Counters have no visible effect by themselves,
1150+
[=Counters=] have no visible effect by themselves,
11511151
but their values can be used
11521152
with the ''counter()'' and ''counters()'' functions,
1153-
which represent the counter values as strings or images.
1154-
Their syntax is:
1153+
whose [=used values=] represent counter values as strings or images.
1154+
They are defined as follows:
11551155

11561156
<pre>
11571157
<dfn><<counter>></dfn> = <<counter()>> | <<counters()>>
1158-
<dfn>counter()</dfn> = counter( <<counter-name>>, [ <<counter-style>> | none ]? )
1159-
<dfn>counters()</dfn> = counters( <<counter-name>>, <<string>>, [ <<counter-style>> | none ]? )
1158+
<dfn>counter()</dfn> = counter( <<counter-name>>, <<counter-style>>? )
1159+
<dfn>counters()</dfn> = counters( <<counter-name>>, <<string>>, <<counter-style>>? )
11601160
</pre>
11611161

1162-
For both functions, the first argument represents the name of a counter,
1163-
and if the last argument is omitted it defaults to ''decimal''.
1162+
where <<counter-style>> specifies the [=counter style=]
1163+
for <a lt="generate a counter representation">generating a representation</a>
1164+
of the named counter(s)
1165+
as defined in [[!css-counter-styles-3]] and
11641166

1165-
The used value of ''counter()'' is obtained as follows:
1167+
<dl>
1168+
<dt>counter()
1169+
<dd>
1170+
Represents the value of the [=innermost=] [=counter=]
1171+
in the element’s [=CSS counters set=]
1172+
named <<counter-name>>
1173+
using the [=counter style=] named <<counter-style>>.
11661174

1167-
<ul>
1168-
<li>
1169-
If the second argument to the function is <css>none</css>,
1170-
the function represents the empty string.
1171-
1172-
<li>
1173-
Otherwise, the function represents the string returned when one <a lt="generate a counter representation">generates a counter representation</a>
1174-
for the value of the innermost counter of that name on the element
1175-
(or ''0'' if the element has no counter of that name)
1176-
using the <<counter-style>> specified by the second argument.
1177-
</ul>
1175+
<dt>counters()
1176+
<dd>
1177+
Represents the values of all the [=counters=]
1178+
in the element’s [=CSS counters set=]
1179+
named <<counter-name>>
1180+
using the [=counter style=] named <<counter-style>>,
1181+
sorted in outermost-first to [=innermost=]-last order
1182+
and joined by the specified <<string>>.
1183+
</dl>
1184+
1185+
In both cases,
1186+
if the <<counter-style>> argument is omitted it defaults to ''decimal''.
1187+
1188+
If no [=counter=] named <<counter-name>> exists
1189+
on an element where ''counter()'' or ''counters()'' is used,
1190+
one is first [=instantiated=] with a starting value of ''0''.
11781191

11791192
<div class="example">
11801193
<pre>
@@ -1195,37 +1208,6 @@ Outputting Counters: the ''counter()'' and ''counters()'' functions</h3>
11951208
</pre>
11961209
</div>
11971210

1198-
The used value of ''counters()'' is obtained as follows:
1199-
1200-
<ul>
1201-
<li>
1202-
If the third argument to the function is <css>none</css>,
1203-
the function represents the empty string.
1204-
1205-
<li>
1206-
Otherwise, if the element has no counters of that name,
1207-
the function represents the string returned when one <a lt="generate a counter representation">generates a counter representation</a>
1208-
for ''0''
1209-
using the <<counter-style>> specified by the third argument.
1210-
1211-
<li>
1212-
Otherwise, if the element has a single counter of that name,
1213-
the function represents the string returned when one <a lt="generate a counter representation">generates a counter representation</a>
1214-
for that counter's value
1215-
using the <<counter-style>> specified by the third argument.
1216-
1217-
<li>
1218-
Otherwise,
1219-
<a>generate a counter representation</a>
1220-
for the values of all counters of the given name on the element
1221-
using the <<counter-style>> specified by the third argument.
1222-
Sort the resulting strings by the nesting depth of the counters they were generated from,
1223-
with the outermost counter first and the innermost last.
1224-
Join the list into a single string,
1225-
inserting the <<string>> specified by the second argument between each item in the list.
1226-
The function represents the string thus produced.
1227-
</ul>
1228-
12291211
<div class='example'>
12301212
The following example shows a simple use of the ''counters()'' function:
12311213

0 commit comments

Comments
 (0)