forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverview.html
More file actions
executable file
·4512 lines (3372 loc) · 170 KB
/
Overview.html
File metadata and controls
executable file
·4512 lines (3372 loc) · 170 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head profile="http://dublincore.org/documents/2008/08/04/dc-html/ ">
<title>CSS Counter Styles Level 3</title>
<link href="http://purl.org/dc/terms/" rel=schema.DC>
<meta content="CSS Counter Styles Level 3" name=DC.title>
<meta content=text name=DC.type>
<meta content=2012-09-25 name=DC.issued>
<meta content="http://dev.w3.org/csswg/css-counter-styles-3/"
name=DC.creator>
<meta content=W3C name=DC.publisher>
<meta content="http://www.w3.org/TR/2012/ED-css-counter-styles-3-20120925/"
name=DC.identifier>
<link href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=DC.rights>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<link href="../default.css" rel=stylesheet type="text/css">
<style>
pre.stylesheet { white-space: pre-wrap; }
</style>
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel=stylesheet
type="text/css">
<body>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1>CSS Counter Styles Level 3</h1>
<dl>
<dt>This version:
<dd><!--<a href="http://www.w3.org/TR/2012/WD-css-counter-styles-3-20120925">http://www.w3.org/TR/2012/WD-css-counter-styles-3-20120925</a>-->
<a
href="http://dev.w3.org/csswg/css-counter-styles-3/">http://dev.w3.org/csswg/css-counter-styles-3/</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css-counter-styles-3/">http://www.w3.org/TR/css-counter-styles-3/</a>
<dt>Editor's Draft:
<dd><a
href="http://dev.w3.org/csswg/css-counter-styles-3/">http://dev.w3.org/csswg/css-counter-styles-3/</a>
<dt>Previous version:
<dd><a
href="http://www.w3.org/TR/2002/WD-css3-lists-20021107/">http://www.w3.org/TR/2002/WD-css3-lists-20021107/</a>
<dt>Issue Tracking:
<dd><a
href="https://www.w3.org/Bugs/Public/buglist.cgi?product=CSS&component=Counter%20Styles&resolution=---">Bugzilla</a>
<dt>Feedback:
<dd><a
href="http://lists.w3.org/Archives/Public/www-style/">www-style@w3.org</a>
with subject line “<kbd>[[css-counter-styles]] <var>… message topic
…</var></kbd>”
<dt>Editor:
<dd class=vcard> <a class=url href="http://xanthir.com/contact/"> <span
class=fn>Tab Atkins Jr.</span>, </a> <span class=org>Google, Inc.</span>
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2012 <a href="http://www.w3.org/"><abbr
title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><abbr
title="Massachusetts Institute of Technology">MIT</abbr></a>, <a
href="http://www.ercim.eu/"><abbr
title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract> Abstract</h2>
<p> This module introduces the ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule, which allows authors to
define their own custom <i>counter styles</i> for use with CSS list-marker
and generated-content counters <a href="#CSS3LIST"
rel=biblioentry>[CSS3LIST]<!--{{CSS3LIST}}--></a>. It also predefines a
set of common counter styles, including the ones present in CSS2 and
CSS2.1. <a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for
describing the rendering of structured documents (such as HTML and XML) on
screen, on paper, in speech, etc.
<h2 class="no-num no-toc" id=status> Status of this document</h2>
<!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. Its publication here does
not imply endorsement of its contents by W3C. Don't cite this document
other than as work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
mailing list <a
href="mailto:www-style@w3.org?Subject=%5Bcss-counter-styles-3%5D%20PUT%20SUBJECT%20HERE">
www-style@w3.org</a> (see <a
href="http://www.w3.org/Mail/Request">instructions</a>) is preferred for
discussion of this specification. When sending e-mail, please put the text
“css-counter-styles-3” in the subject, preferably like this:
“[<!---->css-counter-styles-3<!---->] <em>…summary of
comment…</em>”
<p>This document was produced by the <a href="/Style/CSS/members">CSS
Working Group</a> (part of the <a href="/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent
Policy</a>. W3C maintains a <a href="/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures</a> made in
connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the
W3C Patent Policy</a>.</p>
<!--end-status-->
<p> The following counter styles are at-risk: ‘<a
href="#cjk-decimal"><code class=css>cjk-decimal</code></a>’, ‘<a
href="#hebrew"><code class=css>hebrew</code></a>’, ‘<a
href="#hiragana"><code class=css>hiragana</code></a>’, ‘<a
href="#hiragana-iroha"><code class=css>hiragana-iroha</code></a>’, ‘<a
href="#katakana"><code class=css>katakana</code></a>’, ‘<a
href="#katakana-iroha"><code class=css>katakana-iroha</code></a>’, ‘<a
href="#japanese-informal0"><code
class=css>japanese-informal</code></a>’, ‘<a
href="#japanese-formal0"><code class=css>japanese-formal</code></a>’,
‘<a href="#korean-hangul-formal0"><code
class=css>korean-hangul-formal</code></a>’, ‘<a
href="#korean-hanja-informal0"><code
class=css>korean-hanja-informal</code></a>’, ‘<a
href="#korean-hanja-formal0"><code
class=css>korean-hanja-formal</code></a>’, ‘<a
href="#simp-chinese-informal0"><code
class=css>simp-chinese-informal</code></a>’, ‘<a
href="#simp-chinese-formal0"><code
class=css>simp-chinese-formal</code></a>’, ‘<a
href="#trad-chinese-informal0"><code
class=css>trad-chinese-informal</code></a>’, ‘<a
href="#trad-chinese-formal0"><code
class=css>trad-chinese-formal</code></a>’, and ‘<a
href="#ethiopic-numeric"><code class=css>ethiopic-numeric</code></a>’.
<h2 class="no-num no-toc" id=contents> Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#intro"><span class=secno>1. </span> Introduction</a>
<li><a href="#counter-styles"><span class=secno>2. </span> Counter
Styles</a>
<li><a href="#the-counter-style-rule"><span class=secno>3. </span>
Defining Custom Counter Styles: the ‘<code
class=css>@counter-style</code>’ rule</a>
<ul class=toc>
<li><a href="#counter-style-system"><span class=secno>3.1. </span>
Counter algorithms: the ‘<code class=property>system</code>’
descriptor</a>
<ul class=toc>
<li><a href="#cyclic-system"><span class=secno>3.1.1. </span> Cycling
Symbols: the ‘<code class=css>cyclic</code>’ system</a>
<li><a href="#fixed-system"><span class=secno>3.1.2. </span>
Exhaustible Symbols: the ‘<code class=css>fixed</code>’
system</a>
<li><a href="#symbolic-system"><span class=secno>3.1.3. </span>
Repeating Symbols: the ‘<code class=css>symbolic</code>’
system</a>
<li><a href="#alphabetic-system"><span class=secno>3.1.4. </span>
Bijective Numerals: the ‘<code class=css>alphabetic</code>’
system</a>
<li><a href="#numeric-system"><span class=secno>3.1.5. </span>
Positional Numerals: the ‘<code class=css>numeric</code>’
system</a>
<li><a href="#additive-system"><span class=secno>3.1.6. </span>
Accumulating Numerals: the ‘<code class=css>additive</code>’
system</a>
<li><a href="#override-system"><span class=secno>3.1.7. </span>
Tweaking Existing Counter Styles: the ‘<code
class=css>override</code>’ system</a>
</ul>
<li><a href="#counter-style-negative"><span class=secno>3.2. </span>
Formatting negative values: the ‘<code
class=property>negative</code>’ descriptor</a>
<li><a href="#counter-style-prefix"><span class=secno>3.3. </span>
Symbols before the marker: the ‘<code class=property>prefix</code>’
descriptor</a>
<li><a href="#counter-style-suffix"><span class=secno>3.4. </span>
Symbols after the marker: the ‘<code class=property>suffix</code>’
descriptor</a>
<li><a href="#counter-style-range"><span class=secno>3.5. </span>
Limiting the counter scope: the ‘<code class=property>range</code>’
descriptor</a>
<li><a href="#counter-style-fallback"><span class=secno>3.6. </span>
Defining fallback: the ‘<code class=property>fallback</code>’
descriptor</a>
<li><a href="#counter-style-symbols"><span class=secno>3.7. </span>
Marker characters: the ‘<code class=property>symbols</code>’ and
‘<code class=property>additive-symbols</code>’ descriptors</a>
</ul>
<li><a href="#symbols-function"><span class=secno>4. </span> Defining
Anonymous Counter Styles: the ‘<code class=css>symbols()</code>’
function</a>
<li><a href="#predefined-counters"><span class=secno>5. </span> Simple
Predefined Counter Styles</a>
<ul class=toc>
<li><a href="#simple-numeric"><span class=secno>5.1. </span> Numeric:
‘<code class=css>decimal</code>’, ‘<code
class=css>decimal-leading-zero</code>’, ‘<code
class=css>cjk-decimal</code>’, ‘<code
class=css>lower-roman</code>’, ‘<code
class=css>upper-roman</code>’, ‘<code class=css>armenian</code>’,
‘<code class=css>georgian</code>’, ‘<code
class=css>hebrew</code>’</a>
<li><a href="#simple-alphabetic"><span class=secno>5.2. </span>
Alphabetic: ‘<code class=css>lower-alpha</code>’, ‘<code
class=css>lower-latin</code>’, ‘<code
class=css>upper-alpha</code>’, ‘<code
class=css>upper-latin</code>’, ‘<code
class=css>lower-greek</code>’, ‘<code class=css>hiragana</code>’,
‘<code class=css>hiragana-iroha</code>’, ‘<code
class=css>katakana</code>’, ‘<code
class=css>katakana-iroha</code>’</a>
<li><a href="#simple-symbolic"><span class=secno>5.3. </span> Symbolic:
‘<code class=css>disc</code>’, ‘<code class=css>circle</code>’,
‘<code class=css>square</code>’</a>
</ul>
<li><a href="#complex-predefined-counters"><span class=secno>6. </span>
Complex Predefined Counter Styles</a>
<ul class=toc>
<li><a href="#complex-cjk"><span class=secno>6.1. </span> Longhand East
Asian Counter Styles: ‘<code class=css>japanese-informal</code>’,
‘<code class=css>japanese-formal</code>’, ‘<code
class=css>korean-hangul-formal</code>’, ‘<code
class=css>korean-hanja-informal</code>’, ‘<code
class=css>korean-hanja-formal</code>’, ‘<code
class=css>simp-chinese-informal</code>’, ‘<code
class=css>simp-chinese-formal</code>’, ‘<code
class=css>trad-chinese-informal</code>’, ‘<code
class=css>trad-chinese-formal</code>’</a>
<ul class=toc>
<li><a href="#limited-cjk"><span class=secno>6.1.1. </span>
Limited-range Implementation (required)</a>
<li><a href="#extended-cjk"><span class=secno>6.1.2. </span> Extended
Implementation (optional)</a>
</ul>
<li><a href="#ethiopic-numeric-counter-style"><span class=secno>6.2.
</span> Ethiopic Numeric Counter Style: ‘<code
class=css>ethiopic-numeric</code>’</a>
</ul>
<li><a href="#apis"><span class=secno>7. </span>APIs</a>
<ul class=toc>
<li><a href="#extentions-to-cssrule-interface"><span class=secno>7.1.
</span> Extensions to the <code>CSSRule</code> interface</a>
<li><a href="#the-csscounterstylerule-interface"><span class=secno>7.2.
</span> The <code>CSSCounterStyleRule</code> interface</a>
</ul>
<li class=no-num><a href="#acknowledgments"> Acknowledgments</a>
<li class=no-num><a href="#conformance"> Conformance</a>
<ul class=toc>
<li class=no-num><a href="#conventions"> Document Conventions</a>
<li class=no-num><a href="#conformance-classes"> Conformance Classes</a>
<li class=no-num><a href="#partial"> Partial Implementations</a>
<li class=no-num><a href="#experimental"> Experimental
Implementations</a>
<li class=no-num><a href="#testing"> Non-Experimental
Implementations</a>
</ul>
<li class=no-num><a href="#references">References</a>
<ul class=toc>
<li class=no-num><a href="#normative-references">Normative
references</a>
<li class=no-num><a href="#other-references">Other references</a>
</ul>
<li class=no-num><a href="#property-index">Property index</a>
<li class=no-num><a href="#index">Index</a>
</ul>
<!--end-toc-->
<hr>
<h2 id=intro><span class=secno>1. </span> Introduction</h2>
<p> CSS 1 defined a handful of useful counter styles based on the styles
that HTML traditionally allowed on ordered and unordered lists. While this
was expanded slightly by CSS2.1, it doesn't address the needs of worldwide
typography.
<p> This module introduces the ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule which allows CSS to address
this in an open-ended manner, by allowing the author to define their own
counter styles. These styles can then be used in the ‘<code
class=property>list-style-type</code>’ property or in the <code
title=counter-function>counter()</code> and <code
title=counters-function>counters()</code> functions. It also defines some
additional predefined counter styles, particularly ones which are common
but complicated to represent with ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’.
<h2 id=counter-styles><span class=secno>2. </span> Counter Styles</h2>
<p> A <dfn id=counter-style>counter style</dfn> defines how to convert a
counter value into a string. Counter styles are composed of:
<ul>
<li> a <dfn id=name title=counter-name>name</dfn>, to identify the style
<li> an <dfn id=algorithm title=counter-algorithm>algorithm</dfn> that
transforms counter values into a string representation
<li> a <dfn id=negative-sign title=counter-negative>negative sign</dfn>,
which is prepended or appended to the representation of a negative
counter value
<li> a <dfn id=prefix title=counter-prefix>prefix</dfn>, to prepend to the
representation
<li> a <dfn id=suffix title=counter-suffix>suffix</dfn>, to append to the
representation
<li> a <dfn id=range title=counter-range>range</dfn>, which limits the
values that a counter style handles
<li> and a <dfn id=fallback-style title=counter-fallback>fallback
style</dfn>, to render the representation with when the counter value is
outside the counter style's range or the counter style otherwise can't
render the counter value
</ul>
<p> When asked to <dfn id=generate-a-counter-representation
title=generate-a-counter>generate a counter representation</dfn> using a
particular counter style for a particular counter value, follow these
steps:
<ol>
<li> If the counter value is outside the <a href="#range"><i
title=counter-range>range</i></a> of the counter style, exit this
algorithm and instead <a href="#generate-a-counter-representation"><i
title=generate-a-counter>generate a counter representation</i></a> using
the counter style's fallback style and the same counter value.
<li> Using the counter value and the <a href="#algorithm"><i
title=counter-algorithm>counter algorithm</i></a> for the counter style,
generate an initial representation for the counter value.
<li> Return the representation.
</ol>
<p class=note> Note that the prefix and suffix don't play a part in this
algorithm. This is intentional; the prefix and suffix aren't part of the
string returned by the counter() or counters() functions. Instead, the
prefix and suffix are added by the algorithm that constructs the value of
the ‘<code class=property>contents</code>’ property for the ‘<code
class=css>::marker</code>’ pseudo-element. This also implies that the
prefix and suffix always come from the specified counter-style, even if
the actual representation is constructed by a fallback style.
<h2 id=the-counter-style-rule><span class=secno>3. </span> Defining Custom
Counter Styles: the ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule</h2>
<p> The <dfn id=at-counter-style>‘<code
class=css>@counter-style</code>’</dfn> rule allows authors to define a
custom <a href="#counter-style"><i>counter style</i></a>. The components
of a <a href="#counter-style"><i>counter style</i></a> are specified by
descriptors in the ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule. The <a href="#algorithm"><i
title=counter-algorithm>algorithm</i></a> is specified implicitly by a
combination of the ‘<a href="#descdef-system"><code
class=css>system</code></a>’, ‘<a href="#descdef-symbols"><code
class=css>symbols</code></a>’, and ‘<a
href="#descdef-additive-symbols"><code
class=css>additive-symbols</code></a>’ properties.
<p> The general form of an ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule is:
<pre>
@counter-style <i><counter-style-name></i> {
[ descriptor: value; ]+
}
</pre>
<p class=issue> This isn't strictly correct. For example, multiple
semicolons in a row are valid. This should be done with some productions
from the Syntax spec, so I can just say <code><declaration-list></code>
or something.
<p> The <i><counter-style-name></i> must be be a valid identifier and
must not be ‘<a href="#decimal"><code class=css>decimal</code></a>’ or
‘<code class=css>none</code>’, or else the rule is invalid. (Note,
however, that some names, like ‘<code class=css>inside</code>’ or
‘<code class=css>initial</code>’, might conflict with the existing
values of properties like ‘<code class=property>list-style</code>’,
and thus won't be usable there.)
<p class=issue> The names should be case-insensitive, but we haven't yet
figured out exactly which kind of insensitivity we want for CSS in
general.
<p> Each ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule specifies a value for every
counter-style descriptor, either implicitly or explicitly. Those not given
explicit value in the rule take the initial value listed with each
descriptor in this specification. These descriptors apply solely within
the context of the ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule in which they are defined, and
do not apply to document language elements. There is no notion of which
elements the descriptors apply to or whether the values are inherited by
child elements. When a given descriptor occurs multiple times in a given
‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule, only the last specified value
is used; all prior values for that descriptor must be ignored.
<p> Defining a ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ makes it available to the entire
document in which it is included. If multiple ‘<a
href="#at-counter-style"><code class=css>@counter-style</code></a>’
rules are defined with the same name, only one wins, according to standard
cascade rules. ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rules cascade "atomically": if one
replaces another of the same name, it replaces it <em>entirely</em>,
rather than just replacing the specific descriptors it specifies.
<p> This at-rule conforms with the forward-compatible parsing requirement
of CSS; conformant parsers that don't understand these rules will ignore
them without error. Any descriptors that are not recognized or implemented
by a given user agent must be ignored in their entirety; they do not make
the ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule invalid.
<h3 id=counter-style-system><span class=secno>3.1. </span> Counter
algorithms: the ‘<a href="#descdef-system"><code
class=property>system</code></a>’ descriptor</h3>
<table class=descdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=descdef-system>system</dfn>
<tr>
<th>Value:
<td>repeating | numeric | alphabetic | symbolic | additive | <span
class=nobr>[fixed <integer>?]</span> | <span class=nobr>[ override
<counter-style-name> ]</span>
<tr>
<th>Initial:
<td>symbolic
</table>
<p>The ‘<a href="#descdef-system"><code
class=property>system</code></a>’ descriptor specifies which algorithm
will be used to construct the counter's representation based on the
counter value. For example, ‘<a href="#cyclic"><code
class=css>cyclic</code></a>’ counter styles just cycle through their
symbols repeatedly, while ‘<a href="#numeric"><code
class=css>numeric</code></a>’ counter styles interpret their symbols as
digits and build their representation accordingly. The systems are defined
as follows:
<h4 id=cyclic-system><span class=secno>3.1.1. </span> Cycling Symbols: the
‘<a href="#cyclic"><code class=css>cyclic</code></a>’ system</h4>
<p> The <dfn id=cyclic>‘<code class=css>cyclic</code>’</dfn> counter
system cycles repeatedly through its provided symbols, looping back to the
beginning when it reaches the end of the list. It can be used for simple
bullets (just provide a single <a href="#counter-symbol"><i>counter
symbol</i></a>), or for cycling through multiple symbols. The first <a
href="#counter-symbol"><i>counter symbol</i></a> is used as the
representation of the value 1, the second <a
href="#counter-symbol"><i>counter symbol</i></a> (if it exists) is used as
the representation of the value 2, etc.
<p> If the system is ‘<a href="#cyclic"><code
class=css>cyclic</code></a>’, the ‘<a href="#descdef-symbols"><code
class=property>symbols</code></a>’ descriptor must contain at least one
<a href="#counter-symbol"><i>counter symbol</i></a>, or else the ‘<a
href="#at-counter-style"><code class=css>@counter-style</code></a>’ rule
is invalid. This system is defined over all counter values.
<div class=example>
<p>A "triangle bullet" counter style can be defined as:
<pre>
@counter-style <dfn id=triangle>triangle</dfn> {
system: cyclic;
symbols: ‣;
suffix: '';
}
</pre>
<p>It will then produce lists that look like:
<pre>
‣ One
‣ Two
‣ Three
</pre>
</div>
<p> If there are <var>N</var> <i>counter symbols</i> and a representation
is being constructed for the integer <var>value</var>, the representation
is the <a href="#counter-symbol"><i>counter symbol</i></a> at index (
(<var>value</var>-1) mod <var>N</var>) of the list of <i>counter
symbols</i> (0-indexed).
<h4 id=fixed-system><span class=secno>3.1.2. </span> Exhaustible Symbols:
the ‘<a href="#fixed"><code class=css>fixed</code></a>’ system</h4>
<p> The <dfn id=fixed>‘<code class=css>fixed</code>’</dfn> counter
system runs through its list of counter symbols once, then falls back. It
is useful for representing counter styles that only have a finite number
of representations. For example, Unicode defines several limited-length
runs of special characters meant for lists, such as circled digits.
<p> If the system is ‘<a href="#fixed"><code
class=css>fixed</code></a>’, the ‘<a href="#descdef-symbols"><code
class=property>symbols</code></a>’ descriptor must contain at least one
<a href="#counter-symbol"><i>counter symbol</i></a>, or else the ‘<a
href="#at-counter-style"><code class=css>@counter-style</code></a>’ rule
is invalid. This system is defined over counter values in a finite range,
starting with the <a href="#first-symbol-value"><i>first symbol
value</i></a> and having a length equal to the length of the list of
<i>counter symbols</i>.
<p> When this system is specified, it may optionally have an integer
provided after it, which sets the <dfn id=first-symbol-value>first symbol
value</dfn>. If it is omitted, the <a href="#first-symbol-value"><i>first
symbol value</i></a> is 1.
<div class=example>
<p>A "box-corner" counter style can be defined as:
<pre>
@counter-style <dfn id=box-corner>box-corner</dfn> {
system: fixed;
symbols: ◰ ◳ ◲ ◱;
suffix: ':';
}
</pre>
<p>It will then produce lists that look like:
<pre>
◰: One
◳: Two
◲: Three
◱: Four
5: Five
6: Six
</pre>
</div>
<p> The first <a href="#counter-symbol"><i>counter symbol</i></a> is the
representation for the <a href="#first-symbol-value"><i>first symbol
value</i></a>, and subsequent counter values are represented by subsequent
<i>counter symbols</i>. Once the list of <i>counter symbols</i> is
exhausted, further values cannot be represented by this counter style, and
must instead be represented by the fallback counter style.
<h4 id=symbolic-system><span class=secno>3.1.3. </span> Repeating Symbols:
the ‘<a href="#symbolic"><code class=css>symbolic</code></a>’ system</h4>
<p> The ‘<a href="#symbolic"><code class=css>symbolic</code></a>’
counter system cycles repeatedly through its provided symbols, doubling,
tripling, etc. the symbols on each successive pass through the list. For
example, if the original symbols were "*" and "†", then on the second
pass they would instead be "**" and "††", while on the third they
would be "***"and "†††", etc. It can be used for footnote-style
markers, and is also sometimes used for alphabetic-style lists for a
slightly different presentation than what the ‘<a
href="#alphabetic"><code class=css>alphabetic</code></a>’ system
presents.
<p> If the system is <dfn id=symbolic>‘<code
class=css>symbolic</code>’</dfn>, the ‘<a
href="#descdef-symbols"><code class=property>symbols</code></a>’
descriptor must contain at least one <a href="#counter-symbol"><i>counter
symbol</i></a>, or else the ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule is invalid. This system is
defined only over strictly positive counter values.
<div class=example>
<p>An "footnote" counter style can be defined as:
<pre>
@counter-style <dfn id=footnote>footnote</dfn> {
system: symbolic;
symbols: * ⁑ † ‡;
suffix: '';
}
</pre>
<p>It will then produce lists that look like:
<pre>
*. One
⁑. Two
†. Three
‡. Four
**. Five
⁑⁑. Six
</pre>
</div>
<div class=example>
<p> Some style guides mandate a list numbering that looks similar to ‘<a
href="#upper-alpha"><code class=css>upper-alpha</code></a>’, but
repeats differently after the first 26 values, instead going "AA", "BB",
"CC", etc. This can be achieved with the symbolic system:
<pre>
@counter-style <dfn id=upper-alpha-legal>upper-alpha-legal</dfn> {
system: symbolic;
symbols: A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z;
}</pre>
<p> This style is identical to ‘<a href="#upper-alpha"><code
class=css>upper-alpha</code></a>’ through the first 27 values, but they
diverge after that, with ‘<a href="#upper-alpha"><code
class=css>upper-alpha</code></a>’ going "AB", "AC", "AD", etc. Starting
at the 53rd value, ‘<a href="#upper-alpha"><code
class=css>upper-alpha</code></a>’ goes "BA", "BB", "BC", etc., while
this style jumps into triple digits with "AAA", "BBB", "CCC", etc.
</div>
<p> To construct the representation, run the following algorithm:
<p> Let <var>N</var> be the length of the list of <i>counter symbols</i>,
<var>value</var> initially be the counter value, <var>S</var> initially be
the empty string, and <var>symbol(n)</var> be the nth <a
href="#counter-symbol"><i>counter symbol</i></a> in the list of <i>counter
symbols</i> (0-indexed).
<ol>
<li>Let the <var>chosen symbol</var> be <code
class=inline>symbol(<var>value</var> mod <var>N</var>)</code>.
<li>Let the <var>representation length</var> be <code class=inline>floor(
(<var>value</var> - 1) / <var>N</var> )</code>.
<li>Append the <var>chosen symbol</var> to <var>S</var> a number of times
equal to the <var>representation length</var>.
</ol>
<p>Finally, return <var>S</var>.
<p> The ‘<a href="#symbolic"><code class=css>symbolic</code></a>’
system will produce representations with sizes that are linear in the
magnitude of the counter value. This can potentially be abused to generate
excessively large representations and consume undue amounts of the user's
memory or even hang their browser. User agents must support
representations at least 20 characters long, but they may choose to
instead use the fallback style for representations that would be longer
than 20 characters.
<h4 id=alphabetic-system><span class=secno>3.1.4. </span> Bijective
Numerals: the ‘<a href="#alphabetic"><code
class=css>alphabetic</code></a>’ system</h4>
<p> The ‘<a href="#alphabetic"><code class=css>alphabetic</code></a>’
counter system interprets the list of <i>counter symbols</i> as digits to
an <em title="">alphabetic</em> numbering system, similar to the default
‘<a href="#lower-alpha"><code class=css>lower-alpha</code></a>’
counter style, which wraps from ‘<code class=property>a</code>’,
‘<code class=property>b</code>’, ‘<code class=property>c</code>’,
to ‘<code class=property>aa</code>’, ‘<code
class=property>ab</code>’, ‘<code class=property>ac</code>’.
Alphabetic numbering systems do not contain a digit representing 0; so the
first value when a new digit is added is composed solely of the first
digit. Alphabetic numbering systems are commonly used for lists, and also
appear in many spreadsheet programs to number columns. The first <a
href="#counter-symbol"><i>counter symbol</i></a> in the list is
interpreted as the digit 1, the second as the digit 2, and so on.
<p> If the system is <dfn id=alphabetic>‘<code
class=css>alphabetic</code>’</dfn>, the ‘<a
href="#descdef-symbols"><code class=property>symbols</code></a>’
descriptor must contain at least two <i>counter symbols</i>, or else the
‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule is invalid. This system is
defined only over strictly positive counter values.
<div class=example>
<p>A counter style using go stones can be defined as:
<pre>
@counter-style <dfn id=go>go</dfn> {
system: alphabetic;
symbols: url(white.svg) url(black.svg);
suffix: '';
}
</pre>
<p>It will then produce lists that look like:
<div class=alphabetic-example> <span><img alt=""
src="images/white.svg"></span> One<br>
<span><img alt="" src="images/black.svg"></span> Two<br>
<span><img alt="" src="images/white.svg"><img alt=""
src="images/white.svg"></span> Three<br>
<span><img alt="" src="images/white.svg"><img alt=""
src="images/black.svg"></span> Four<br>
<span><img alt="" src="images/black.svg"><img alt=""
src="images/white.svg"></span> Five<br>
<span><img alt="" src="images/black.svg"><img alt=""
src="images/black.svg"></span> Six<br>
<span><img alt="" src="images/white.svg"><img alt=""
src="images/white.svg"><img alt="" src="images/white.svg"></span> Seven</div>
<p class=note>This example requires support for SVG images to display
correctly.
</div>
<div class=example>
<p>Alphabetic styles may also be used to simulate a fixed-width numeric
style:
<pre>
@counter-style <dfn id=fixed-decimal>fixed-decimal</dfn> {
system: alphabetic;
symbols: '0' '1' '2' '3' '4' '5' '6' '7' '8' '9';
}
ol {
list-style: fixed-decimal;
counter-reset: list-item 1111;
}
</pre>
<p>This will produce lists that look like:
<pre>
0001. One
0002. Two
0003. Three
0004. Four
0005. Five
0006. Six
</pre>
<p>Two-digit numbers start at value 11, three-digit numbers start at value
111, etc..
<p class=issue>Should I instead explicitly provide a fixed-width numeric
counter system? I'd like to see if this sort of numbering is used in the
wild first.
</div>
<p> If there are <var>N</var> <i>counter symbols</i>, the representation is
a base <var>N</var> alphabetic number using the <i>counter symbols</i> as
digits. To construct the representation, run the following algorithm:
<p> Let <var>N</var> be the length of the list of <i>counter symbols</i>,
<var>value</var> initially be the counter value, <var>S</var> initially be
the empty string, and <var>symbol(n)</var> be the nth <a
href="#counter-symbol"><i>counter symbol</i></a> in the list of <i>counter
symbols</i> (0-indexed).
<p>While <var>value</var> is not equal to 0:
<ol>
<li>Set <var>value</var> to <code><var>value</var> - 1</code>.
<li>Prepend <var>symbol( <var>value</var> mod <var>N</var> )</var> to
<var>S</var>.
<li>Set <var>value</var> to <code>floor( <var>value</var> / <var>N</var>
)</code>.
</ol>
<p>Finally, return <var>S</var>.
<h4 id=numeric-system><span class=secno>3.1.5. </span> Positional Numerals:
the ‘<a href="#numeric"><code class=css>numeric</code></a>’ system</h4>
<p> The <dfn id=numeric>‘<code class=css>numeric</code>’</dfn> counter
system interprets the list of <i>counter symbols</i> as digits to a
"place-value" numbering system, similar to the default ‘<a
href="#decimal"><code class=css>decimal</code></a>’ counter style. The
first <a href="#counter-symbol"><i>counter symbol</i></a> in the list is
interpreted as the digit 0, the second as the digit 1, and so on.
<p> If the system is ‘<a href="#numeric"><code
class=css>numeric</code></a>’, the ‘<a href="#descdef-symbols"><code
class=property>symbols</code></a>’ descriptor must contain at least two
<i>counter symbols</i>, or else the ‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule is invalid. This system is
defined over all counter values.
<div class=example>
<p>A "trinary" counter style can be defined as:
<pre>
@counter-style <dfn id=trinary>trinary</dfn> {
system: numeric;
symbols: '0' '1' '2';
}
</pre>
<p>It will then produce lists that look like:
<pre>
1. One
2. Two
10. Three
11. Four
12. Five
20. Six
</pre>
</div>
<p> If there are <var>N</var> <i>counter symbols</i>, the representation is
a base <var>N</var> number using the <i>counter symbols</i> as digits. To
construct the representation, run the following algorithm:
<p> Let <var>N</var> be the length of the list of <i>counter symbols</i>,
<var>value</var> initially be the counter value, <var>S</var> initially be
the empty string, <a href="#descdef-negative"><var>negative</var></a> be a
boolean flag that is initially false, and <var>symbol(n)</var> be the nth
<a href="#counter-symbol"><i>counter symbol</i></a> in the list of
<i>counter symbols</i> (0-indexed).
<ol>
<li>If <var>value</var> is 0, append <var>symbol(0)</var> to <var>S</var>
and return <var>S</var>.
<li>If <var>value</var> is negative, run the next step of this algorithm
with <var>value</var> being the absolute value of <var>value</var>
instead.
<li>While <var>value</var> is not equal to 0:
<ol>
<li>Prepend <var>symbol( <var>value</var> mod <var>N</var> )</var> to
<var>S</var>.
<li>Set <var>value</var> to <code>floor( <var>value</var> / <var>N</var>
)</code>.
</ol>
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the
counter style's <a href="#negative-sign"><i
title=counter-negative>negative sign</i></a>, as specified in the section
for the <a href="#counter-style-negative">negative descriptor</a>.
<li>Return <var>S</var>.
</ol>
<h4 id=additive-system><span class=secno>3.1.6. </span> Accumulating
Numerals: the ‘<a href="#additive"><code
class=css>additive</code></a>’ system</h4>
<p> The <dfn id=additive>‘<code class=css>additive</code>’</dfn>
counter system is used to represent "sign-value" numbering systems, which,
rather than using reusing digits in different positions to change their
value, define additional digits with much larger values, so that the value
of the number can be obtained by adding all the digits together. This is
used in Roman numerals and other numbering systems around the world.
<p> If the system is ‘<a href="#additive"><code
class=css>additive</code></a>’, the ‘<a
href="#descdef-additive-symbols"><code
class=property>additive-symbols</code></a>’ descriptor must contain at
least one <a href="#additive-tuple"><i>additive tuple</i></a>, or else the
‘<a href="#at-counter-style"><code
class=css>@counter-style</code></a>’ rule is invalid. This system is
nominally defined over all counter values (see algorithm, below, for exact
details).
<div class=example>
<p>A "dice" counter style can be defined as:
<pre>
@counter-style <dfn id=dice>dice</dfn> {
system: additive;
additive-symbols: 6 ⚅, 5 ⚄, 4 ⚃, 3 ⚂, 2 ⚁, 1 ⚀;
suffix: '';
}
</pre>
<p>It will then produce lists that look like:
<pre>
⚀ One
⚁ Two
⚂ Three
...
⚅⚄ Eleven
⚅⚅ Twelve
⚅⚅⚀ Thirteen
</pre>
</div>
<p> To construct the representation, run this algorithm:
<p> Let <var>value</var> initially be the counter value, <var>S</var>
initially be the empty string, and <var>symbol list</var> initially be the
list of <i>additive tuples</i>.
<ol>
<li>If <var>value</var> is initially 0, and there is an <a
href="#additive-tuple"><i>additive tuple</i></a> with a weight of 0,
append that tuple's <a href="#counter-symbol"><i>counter symbol</i></a>
to S and return S.
<li>If <var>value</var> is negative, run the next step of this algorithm
with <var>value</var> being the absolute value of <var>value</var>
instead.
<li>While <var>value</var> is greater than 0 and there are elements left
in the <var>symbol list</var>:
<ol>
<li>Pop the first <a href="#additive-tuple"><i>additive tuple</i></a>
from the <var>symbol list</var>. This is the <dfn id=current-tuple
title="current tuple|current tuple's">current tuple</dfn>.
<li>Append the <a href="#current-tuple"><i>current tuple</i></a>'s
<a href="#counter-symbol"><i>counter symbol</i></a> to <var>S</var>
<code>floor( <var>value</var> / <var><a
href="#current-tuple"><i>current tuple's</i></a> weight</var> )</code>
times (this may be 0).
<li>Decrement <var>value</var> by the <var><a
href="#current-tuple"><i>current tuple's</i></a> weight multiplied by
the number of times the <a href="#current-tuple"><i>current
tuple</i></a> was appended to <var>S</var> in the previous step. </var>
</ol>
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the
counter style's <a href="#negative-sign"><i
title=counter-negative>negative sign</i></a>, as specified in the section
for the <a href="#counter-style-negative">negative descriptor</a>.
<li>If the loop ended because <var>value</var> is 0, return S. Otherwise,
the given counter value cannot be represented by this counter style, and
must instead be represented by the fallback counter style.
</ol>
<p> The ‘<a href="#additive"><code class=css>additive</code></a>’
system will produce representations with sizes that are linear in the
magnitude of the counter value. This can potentially be abused to generate
excessively large representations and consume undue amounts of the user's