-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathOverview.src.html
More file actions
3421 lines (2836 loc) · 141 KB
/
Overview.src.html
File metadata and controls
3421 lines (2836 loc) · 141 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>
<title>CSS Lists and Counters Module Level 3</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<link rel="stylesheet" type="text/css" href="http://dev.w3.org/csswg/css-module/default.css">
<style>
code.inline { white-space: nowrap; }
.alphabetic-example { font-family: monospace; font-size: 90%; margin: 1em 0 1em 2em; }
.alphabetic-example > span { display: inline-block; width: 50px;}
.alphabetic-example > span > img { width: 16px; height: 16px; }
pre > code { white-space: pre-wrap; }
.nobr { white-space: nowrap;}
</style>
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-ED">
</head><body>
<div class="head">
<!--logo-->
<h1>CSS Lists and Counters Module Level 3</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This version:
<dd><!--<a href="http://www.w3.org/TR/[YEAR]/WD-[SHORTNAME]-[CDATE]">http://www.w3.org/TR/[YEAR]/WD-[SHORTNAME]-[CDATE]</a></dd>-->
<a href="http://dev.w3.org/csswg/css3-lists/">http://dev.w3.org/csswg/css3-lists/</a></dd>
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/css3-lists/">http://www.w3.org/TR/css3-lists/</a></dd>
<dt>Previous version:</dt>
<dd><a href="http://www.w3.org/TR/2002/WD-css3-lists-20021107/">http://www.w3.org/TR/2002/WD-css3-lists-20021107/</a></dd>
<dt>Editor:</dt>
<dd><a href="http://www.xanthir.com/contact">Tab Atkins Jr.</a>, Google Inc.</dd>
<dt>Previous Editors:</dt> <!-- in the order tantek requested -->
<dd>Ian Hickson, <a href="mailto:ian@hixie.ch">ian@hixie.ch</a></dd>
<dd><span lang="tr">Tantek Çelı̇k</span>, Microsoft Corporation,
<a href="mailto:tantekc@microsoft.com">tantekc@microsoft.com</a></dd>
<dt>Contributors:</dt> <!-- in order of volume of input -->
<dd>Simon Montagu, AOL-TW/Netscape, <a href="mailto:smontagu@netscape.com">smontagu@netscape.com</a></dd>
<dd>Daniel Yacob, <a href="mailto:yacob@geez.org">yacob@geez.org</a></dd>
<dd>Christopher Hoess, <a href="mailto:choess@stwing.upenn.edu">choess@stwing.upenn.edu</a></dd>
<dd>Daniel Glazman, AOL-TW/Netscape, <a href="mailto:glazman@netscape.com">glazman@netscape.com</a></dd>
</dl>
<!--copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id="abstract">
Abstract</h2>
<p>CSS is a language for describing the rendering of structured documents
(such as HTML and XML) on screen, on paper, in speech, etc.
This draft contains the features of CSS level 3 relating to
list styling. It includes and extends the functionality of
CSS level 2 [[!CSS21]], which builds on CSS level 1
[[CSS1]]. The main extensions compared to level 2 are a pseudo-element
representing the list marker,
and a method for authors to define their own list-styles.</p>
<h2 class="no-num no-toc" id="status">
Status of this document</h2>
<!--status-->
<h2 class="no-num no-toc" id="contents">
Table of contents</h2>
<!--toc-->
<hr>
<!-- ====================================================================== -->
<h2>
Introduction</h2>
<p>The list model in this module differs in some important ways from the list model in CSS2,
specifically in its handling of markers. Implementation experience suggested the CSS2 model
overloaded the ::before and ::after pseudo-elements with too much behavior, while at the same time
introducing new properties when existing properties were sufficient.</p>
<p>Most block-level elements in CSS generate one principal block box. In this module, we discuss two
CSS mechanisms that cause an element to have an associated marker: one method associates one
principal block box (for the element's content) with a separate marker box (for decoration such as a
bullet, image, or number), and the other inserts a marker box into the principal box. Unlike :before
and :after content, the marker box cannot affect the position of the principal box, whatever the
positioning scheme.</p>
<div class="html-example">
<p>For instance, the following example illustrates how markers may be used to add parentheses around each numbered list item. This HTML application and style sheet:</p>
<pre>
<style>
li::marker { content: "(" counter(list-item, lower-roman) ")"; }
li { display: list-item; }
</style>
<ol>
<li>This is the first item.</li>
<li>This is the second item.</li>
<li>This is the third item.</li>
</ol></pre>
<p>should produce something like this: </p>
<pre>
(i) This is the first item.
(ii) This is the second item.
(iii) This is the third item.
</pre>
</div>
<p>With descendant selectors and child selectors, it's possible to specify different marker types depending on the depth of embedded lists.</p>
<p class="issue">A future release of this module will probably include ways to render tree
lists.</p>
<!-- ====================================================================== -->
<h2>
Declaring a List Item</h2>
<p>To declare a <dfn>list item</dfn>, the 'display'
property must be set to ''list-item'' or ''inline-list-item'' (defined
later in this section). This, in addition to generating a <code class=css>::marker</code>
pseudo-element and enabling the properties described below for that element,
causes that element to increment the list item counter ''list-item''.
(This does not affect the specified or computed values of the counter
properties.)</p>
<p>The ''list-item'' counter is a real counter,
and can be directly affected using the 'counter-increment' and ''counter-reset''
properties. It can also be used in the ''counter()'' and ''counters()'' functions.</p>
<table class="propdef">
<tbody>
<tr>
<th>Property:
<td>'display'
<tr>
<th>New Value:
<td><dfn>inline-list-item</dfn>
<tr>
<th>Initial:
<td>same as CSS2.1
<tr>
<th>Applies to:
<td>same as CSS2.1
<tr>
<th>Inherited:
<td>same as CSS2.1
<tr>
<th>Percentages:
<td>same as CSS2.1
<tr>
<th>Media:
<td>same as CSS2.1
<tr>
<th>Computed value:
<td>same as CSS2.1
</tbody>
</table>
<p>The ''inline-list-item'' display value makes the element a list item,
which means it can generate a <code class=css>::marker</code> pseudo-element. The element also
affects the predefined ''list-item'' counter, as specified above. Otherwise,
this display value is treated identically to ''inline''.</p>
<p class='note'>This display value is silly, and only necessary because we
haven't yet defined 'display' to be split into subproperties. When that
happens, "being a list item" will just be a property value that can apply
to block, inline, and other elements.</p>
<!-- ====================================================================== -->
<h2 id='marker-content'>
Marker Content: The 'list-style-image' and 'list-style-type' properties</h2>
<table class="propdef"&
6329
gt;
<tr>
<th>Name:
<td><dfn>list-style-image</dfn>
<tr>
<th>Value:
<td><image> | none
<tr>
<th>Initial
<td>none
<tr>
<th>Applies To:
<td><i title="list item">list items</i>
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed Value:
<td>specified value
</table>
<p>The 'list-style-type' property specifies an image that will be used as the list marker. If the value resolves to a valid image, the image must be used as the default contents of the <code class=css>::marker</code> pseudo-element.</p>
<p>If the value ''none'' is provided, or the <i><image></i> doesn't resolve to a valid image, then the default contents are given by 'list-style-type' instead.</p>
<div class="example">
<p>The following example sets the marker at the beginning of each list item to
be the image "ellipse.png".</p>
<pre>LI { list-style-image: url("http://www.example.com/ellipse.png") }</pre>
</div>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>list-style-type</dfn>
<tr>
<th>Value:
<td><string> | <counter-style> | none
<tr>
<th>Initial:
<td>disc
<tr>
<th>Applies To:
<td><i title="list item">list items</i>
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed Value:
<td>specified value
</table>
<p>When the 'list-style-image' property is ''none'' or not a valid image, the 'list-style-type' property must be used to construct the default contents of a list item's marker; otherwise, the 'list-style-type' property must be ignored and have no effect.</p>
<dl>
<dt><string></dt>
<dd>The <code class=css>::marker</code> pseudo-element must use the provided string as its default contents.</dd>
<dt><i><counter-style></i></dt>
<dd>
<p>The <code class=css>::marker</code> pseudo-element's default contents must be the value of the ''list-item'' counter, formatted according to the given counter style. Algorithms for formatting a value according to a counter style are given later in this spec.</p>
<p>This specification defines a method for authors to create their own counter styles, both <a href="#counter-style">named</a> and <a href="#symbols-function">anonymous</a>, which may be used here. Additionally, many useful counter styles are predefined in the sections on <a href="#predefined-counters">Complex Counter Styles</a> and <a href="#ua-stylesheet">Predefined Counter Styles</a>.</p>
</dd>
<dt><dfn>none</dfn></dt>
<dd>The <code class=css>::marker</code> pseudo-element must have no default contents. This will suppress the creation of a marker unless the <code class=css>::marker</code> has its contents specified directly through the 'content' property.</dd>
</dl>
<div class='example'>
<p>The following examples illustrate how to set markers to various values:</p>
<pre>
ul { list-style-type: "★"; }
/* Sets the marker to a "star" character */
p.note {
display: list-item;
list-style-type: "Note:";
list-style-position: inside;
}
/* Gives note paragraphs a marker consisting of the string "Note:" */
ol { list-style-type: upper-roman; }
/* Sets all ordered lists to use the upper-roman counter-style
(<a href="#upper-roman">defined in this specification</a>) */
ul { list-style-type: symbols('○' '●' as repeating); }
/* Sets all unordered list items to alternate between empty and
filled circles for their markers. */
ul { list-style-type: none; }
/* Suppresses the marker entirely, unless list-style-image is specified
with a valid image, or the marker's contents are set explicitly via
the 'content' property. */</pre>
</div>
<p>The <i><counter-style></i> type is defined as:</p>
<pre><dfn><counter-style></dfn> = <identifier> | <symbols-function></pre>
<p>where the <identifier> must be the name of a valid custom counter style defined with the ''@counter-style'' rule.</p>
<!-- ====================================================================== -->
<h2 id='list-style-position-property'>
Marker Position: The 'list-style-position' property</h2>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>list-style-position</dfn>
<tr>
<th>Value:
<td>inside | outside
<tr>
<th>Initial:
<td>outside
<tr>
<th>Applies To:
<td><i title="list item">list items</i>
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed Value:
<td>specified value
</table>
<p>This property specifies the position of the <code class=css>::marker</code> pseudo-element's box
in the <i>list item</i>. Values have the following meanings:</p>
<dl>
<dt><dfn>inside</dfn></dt>
<dd>The <code class=css>::marker</code> pseudo-element is a 'display:inline' element placed immediately before the ''::before'' pseudo-element in the <i>list item</i>'s principle box, after which the element's content flows. Note that if there is no inline content, this will create a line box, just as content in an inline ''::before'' pseudo-element would. Also note that all the properties that apply to inline elements apply to the <code class=css>::marker</code> pseudo-element in this state, and this <code class=css>::marker</code> box participates in the inline box model in the normal manner.</dd>
<dt><dfn>outside</dfn></dt>
<dd>As ''inside'', plus the 'position' property on the <code class=css>::marker</code> pseudo-element must computer to ''marker''. The section on the new 'marker' value for 'position' explains the consequences of this. Additionally, the base directionality of the <code class=css>::marker</code> pseudo-element (used as an input to the bidi resolution algorithm) must be taken from the marker's <i>marker positioning reference element</i>.</dd>
</dl>
<p>Note that a marker is only generated if the computed value of the 'content'
property for the element's <code class=css>::marker</code> pseudo-element is not ''none''.</p>
<p class='issue'>Should I make this always compute to ''inside'' when the list item is ''display:inline-list-item''? See the thread at <a href="http://lists.w3.org/Archives/Public/www-style/2011Jun/0232.html">http://lists.w3.org/Archives/Public/www-style/2011Jun/0232.html</a>.</p>
<div class=example>
<p>For example:
<pre>
<style>
ul.compact { list-style: inside; }
ul { list-style: outside; }
</style>
<ul class=compact>
<li>first "inside" list item comes first</li>
<li>second "inside" list item comes first</li>
</ul>
<hr>
<ul>
<li>first "outside" list item comes first</li>
<li>second "outside" list item comes first</li>
</ul></pre>
<p>The above example may be formatted as:</p>
<pre>
* first "inside" list
item comes first
* second "inside" list
item comes second
========================
* first "outside" list
item comes first
* second "outside" list
item comes second</pre>
</div>
<!-- ====================================================================== -->
<h2 id='list-style-property'>
The 'list-style' shorthand property</h2>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>list-style</dfn>
<tr>
<th>Value:
<td><'list-style-type'> || <'list-style-position'> || <'list-style-image'>
<tr>
<th>Initial:
<td>see individual properties
<tr>
<th>Applies To:
<td><i title="list item">list items</i>
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed Value:
<td>see individual properties
</table>
<p>The 'list-style' property is a shorthand notation for setting the
three properties 'list-style-type', 'list-style-image', and 'list-style-position'
at the same place in the style sheet.</p>
<div class="example">
<p>For example:</p>
<pre>
UL { list-style: upper-roman inside } /* Any UL */
UL UL { list-style: circle outside } /* Any UL child of a UL */
</pre>
</div>
<p>Using a value of ''none'' in the shorthand is potentially ambiguous, as ''none'' is a valid value for both 'list-style-image' and 'list-style-type'. To resolve this ambiguity, a value of ''none'' in the shorthand must be applied to whichever of the two properties aren't otherwise set by the shorthand.</p>
<div class='example'>
<pre>
list-style: none disc;
/* Sets the image to "none" and the type to "disc". */
list-style: none url(bullet.png);
/* Sets the image to "url(bullet.png)" and the type to "none". */
list-style: none;
/* Sets both image and type to "none". */
list-style: none disc url(bullet.png);
/* Syntax error */</pre>
</div>
<p>Although authors may specify 'list-style' information directly on list item elements (e.g., LI in HTML), they should do so with care. Consider the following rules:</p>
<div class=example>
<pre>
ol.alpha li { list-style: lower-alpha; }
ul li { list-style: disc; }
/* These won't work as expected. If you nest a <ul>
into an <ol class=alpha>, the first rule's specificity
will make the <ul>'s list items use the lower-alpha style. */
ol.alpha > li { list-style: lower-alpha; }
ul > li { list-style: disc; }
/* These work as intended. */
ol.alpha { list-style: lower-alpha; }
ul { list-style: disc; }
/* So do these, since inheritance will transfer the
'list-style' value to the list items. */</pre>
</div>
<!-- ====================================================================== -->
<h2 id='marker-pseudo-element'>
Markers: The <code class=css>::marker</code> pseudo-element</h2>
<p>Markers are created by setting an element's 'display' property to
''list-item'' or ''inline-list-item''. The <code class=css>::marker</code> pseudo-element is only created if
the computed value of the 'content' property for the pseudo-element is not
''none''.</p>
<p>Just like other generated content, markers generate a box when they're created, which can be styled with the full range of properties and values. Markers are placed at the beginning of their superior parent's content, before the ::before pseudo-element (if it exists). <code class=css>::marker</code> pseudo-elements are inline by default, though certain values for 'list-style-position' on the list item can make the marker box positioned, which can have an effect on the computed value of display.</p>
<div class="example">
<p>In the following example, the content is centered within a marker
box of a fixed width. This document:</p>
<pre>
<style>
li::marker {
content: "(" counter(counter) ")";
width: 6em;
text-align: center;
}
li {
display: list-item;
counter-increment: counter;
}
</style>
<ol>
<li>This is the first item.</li>
<li>This is the second item.</li>
<li>This is the third item.</li>
</ol></pre>
<p>should render something like this: </p>
<pre>
(1) This is the
first item.
(2) This is the
second item.
(3) This is the
third item.</pre>
</div>
<div class="example">
<p>In this example, markers are used to number paragraphs that are designated as "notes":</p>
<pre>
<style>
p { margin-left: 12 em; }
p.note::marker {
content: "Note " counter(note-counter) ":";
text-align: left;
width: 10em;
}
p.note {
display: list-item;
counter-increment: note-counter;
}
</style>
<p>This is the first paragraph in this document.</p>
<p class="note">This is a very short document.</p>
<p>This is the end.</p>
</pre>
<p>It should render something like this:</p>
<pre>
This is the first paragraph
in this document.
Note 1: This is a very short
document.
This is the end.</pre>
</div>
<div class="example">
<p>By using the <code class=css>::marker</code> pseudo-element, a list's markers can be positioned much more flexibly, and even be styled independently from the text of the list item itself:</p>
<pre>
<style>
p { margin-left: 8em } /* Make space for counters */
li { list-style-type: lower-roman; }
li::marker { margin: 0 3em 0 0; color: blue; }
</style>
<p>This is a long preceding paragraph ...</p>
<ol>
<li>This is the first item.</li>
<li>This is the second item.</li>
<li>This is the third item.</li>
</ol>
<p>This is a long following paragraph ...</p></pre>
<p>The preceding document should render something like this: </p>
<pre>
This is a long preceding
paragraph ...
<span style=color:blue>i.</span> This is the first item.
<span style=color:blue>ii.</span> This is the second item.
<span style=color:blue>iii.</span> This is the third item.
This is a long following
paragraph ...</pre>
<p>Previously the only way to style a marker was through inheritance; one had to put the desired marker styling on the list item, and then revert that on a wrapper element around the list item's actual contents. Non-inherited properties like 'margin' couldn't be adjusted at all on the marker.</p>
</div>
<!-- ====================================================================== -->
<h3 id='content-property'>
Generating the computed value of the 'content' property</h3>
<p>If a <code class=css>::marker</code> pseudo-element has its 'content' property set to ''normal'',
the computed value of the marker's 'content' property must be determined
according to the following algorithm:</p>
<ol>
<li>If the computed value of 'list-style-image' is a valid <image>, then
the computed value of the 'content' property is that image.</li>
<li>Otherwise, if the computed value of 'list-style-type' is a <string>, then
the computed value of the 'content' property is that string.</li>
<li>Otherwise, if the computed value of 'list-style-type' is a valid <i><counter-style></i>, then the computed value of the 'content' property is <code><counter-prefix> counter(list-item, <counter-style>) <counter-suffix></code>, where <i><counter-prefix></i> and <i><counter-suffix></i> are the values of the <i title='counter-prefix'>prefix</i> and <i title='counter-suffix'>suffix</i> descriptors for the counter style.</li>
<li>Otherwise the computed value is ''none''.</li>
</ol>
<div class="example">
<p>Given the following style sheet:</p>
<pre>
li { display: list-item; list-style-type: decimal /* initial value */; }
li<code class=css>::marker</code> { content: normal /* initial value */; }</pre>
<p>And the following document fragment:</p>
<pre><li>List Item</li></pre>
<p>The computed value of the 'content' property on the <code class=css>::marker</code> pseudo-element of the list item element is:</p>
<pre>counter(list-item, decimal) "."</pre>
</div>
<!-- ===================================================================== -->
<h2 id='positioning-markers'>
Positioning Markers</h2>
<p>This section introduces a new positioning scheme, designed to model the
way in which "outside" list markers were traditionally positioned in CSS 2.1.
Outside list markers now have their positioning defined in terms of this new
value.</p>
<p>The new positioning scheme defined in this section can be used on all
elements, not just <code class=css>::marker</code> pseudo-elements. In some situations, such as
legal proceedings or official minutes, the precise form that the list marker
takes is a vital part of the content. It's not acceptable for the marker to
change (from a custom-defined marker to a default bullet or alpha marker)
just because the UA is not rendering CSS, or a server error is temporarily
preventing the CSS file from being loaded, as the precise form of the marker
is used to officially refer to that segment. The only way to guarantee that
the marker will be rendered correctly, regardless of whether CSS is applied,
is to specify the marker outside of CSS, directly in the document's markup.
However, the page author may still want to style the marker in many of the
ways that are available to them when using ordinary CSS-generated markers.
To accomodate this, the new positioning scheme can be used to position the
marker-in-content as if it were an ordinary CSS-generated marker.</p>
<h3 id='position-marker'>
The ''marker'' value for 'position'</h3>
<table class="propdef">
<tr>
<th>Property:
<td>'position'
<tr>
<th>New Value:
<td>''marker''
<tr>
<th>Initial:
<td>same as CSS2.1
<tr>
<th>Applies to:
<td>same as CSS2.1
<tr>
<th>Inherited:
<td>same as CSS2.1
<tr>
<th>Percentages:
<td>same as CSS2.1
<tr>
<th>Media:
<td>same as CSS2.1
<tr>
<th>Computed value:
<td>see prose, otherwise same as CSS2.1
</table>
<p>The ''marker'' value for 'position' depends on the element it is set on having a list item ancestor. If the specified value of 'position' is ''marker'' and the element does not have a list item ancestor, 'position' must compute to 'relative' on the element. An element with <code class=css>position:marker</code> counts as <a href="http://www.w3.org/TR/CSS21/visuren.html#absolutely-positioned">absolutely positioned</a>.</p>
<p>To calculate the marker's position, we must first define a few terms:</p>
<dl>
<dt><dfn title="ancestor list item|ancestor list item's">ancestor list item</dfn></dt>
<dd>The <i>ancestor list item</i> is the marker's nearest list item ancestor element.</dd>
<dt><dfn>marker positioning reference element</dfn></dt>
<dd>
<p>If the <i>ancestor list item</i> has ''marker-attachment:list-item'', the <i>marker positioning reference element</i> is the <i>ancestor list item</i>.</p>
<p>Otherwise, if the <i>ancestor list item</i> has ''marker-attachment:list-container'' and has a parent element, the <i>marker positioning reference element</i> is the <i>ancestor list item's</i> parent.</p>
<p>Otherwise, the <i>marker positioning reference element</i> is the <i>ancestor list item</i>.</p>
</dd>
<dt><dfn>list item positioning edge</dfn></dt>
<dd>The border edge of the <i>ancestor list item</i> corresponding to the "start" or "before" edge of the <i>marker positioning reference element</i>, whichever is in the <i>ancestor list item's</i> inline axis.</dd>
<dt><dfn>marker positioning edge</dfn></dt>
<dd>The opposing edge relative to the <i>list item positioning edge</i> on the marker's margin box. For example, if the <i>list item positioning edge ended up being the left border edge of the <i>ancestor list item</i>, the <i>marker positioning edge</i> would be the right margin edge of the marker.</dd>
</dl>
<p>The marker's position in the <i>ancestor list item's</i> block axis is calculated according to the <a href="http://www.w3.org/TR/CSS21/visuren.html#normal-flow">normal flow</a>. <span class='note'>In the Positioned Layout Module this will be defined more precisely in terms of placeholders.</span></p>
<p>The marker's position in the <i>ancestor list item's</i> inline axis must be set such that the <i>marker positioning edge</i> is flush with the <i>list item positioning edge</i>.</p>
<p class='note'>The purpose of this somewhat convoluted definition is to position the marker flush against its list item, and then when "marker-attachment:list-container", keep all the markers for a given list on the same side of their list items even in mixed-direction text, so that authors can specify padding on only one side and still ensure their markers are visible. And on top of all that, do something sane in the face of potentially differing writing-modes on the marker, list item, and container.</p>
<p>All elements or pseudo-elements with <code class=css>"position:marker"</code> that share a common <i>ancestor list item</i> are known as <dfn title='associated-marker'>markers associated with that list item</dfn>.</p>
<p>The 'top', 'right', 'bottom', and 'left' properties specify offsets relative to the top, right, bottom, and left edges (respectively) of the element itself, similar to how relative positioning works.</p>
<div class='example'>
<p>''position:marker'' can be used when the precise list marker is important for the content, not a stylistic choice, but the normal <em>appearance</em> of lists is still desired. For example, this trimmed snippet of the US Code of Laws may be marked up as the following in HTML:</p>
<pre>
<style>
ol { list-style: none; }
.marker { position: marker; }
</style>
<ol>
<li>
<span class='marker'>(a)</span> Definitions.— For purposes of this section—
<ol>
<li><span class='marker'>(1)</span> the term “agency” means agency as...</li>
<li><span class='marker'>(2)</span> the term “individual” means a citizen...</li>
</ol>
</li>
<li>
<span class='marker'>(b)</span> Conditions of Disclosure.— No agency shall disclose...
<ol>
<li><span class='marker'>(1)</span> to those officers and employees of the agency which...</li>
<li><span class='marker'>(2)</span> required under section 552 of this title;</li>
</ol>
</li>
</ol></pre>
<p>The preceding document should render something like this:</p>
<pre>
(a) Definitions.— For purposes of this section—
(1) the term “agency” means agency as...
(2) the term “individual” means a citizen...
(b) Conditions of Disclosure.— No agency shall disclose...
(1) to those officers and employees of the agency which...
(2) required under section 552 of this title;</pre>
<p>Importantly, it will <strong>always</strong> be presented something like that, with those exact list markers, even if the stylesheet is unavailable, so other documents can refer to those list markers and be confident that the reference will always be resolvable.</p>
</div>
<h3 id='marker-attachment'>
The 'marker-attachment' property</h3>
<p>By default, elements or <code class=css>::marker</code> pseudo-elements with ''position:marker'' position themselves according to their list item's directionality. However, if the list item is grouped with several other list items which may have different directionality (for example, multiple <li>s with different "dir" attributes in an <ol> in HTML), it is sometimes more useful to have all the markers line up on one side, so the author can specify a single "gutter" on that side and be assured that all the markers will lie in that gutter and be visible. The 'marker-attachment' property defined in this section allows an author to control this, switching list items to positioning their markers based off the list container's directionality instead.</p>
<table class="propdef">
<tr>
<th>Property:
<td><dfn>marker-attachment</dfn>
<tr>
<th>Value:
<td>list-item | list-container
<tr>
<th>Initial:
<td>list-item
<tr>
<th>Applies to:
<td><i title="list item">list items</i>
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed Value:
<td>specified value
</table>
<p>When a list item has ''marker-attachment:list-item'', any <i title='associated-marker'>markers associated with the list item</i> base their positioning off of the directionality of the list item. When a list item has ''marker-attachment:list-container'', the <i title='associated-marker'>associated markers</i> instead base their positioning off of the directionality of the list item's parent element. The normative meaning of this is specified in the section defining <a href="#position-marker">position:marker</a>.</p>
<div class='example'>
<p>Here is a visual rendering of the effect that 'marker-attachment' can have on a list. Both of the following renderings are generated from the following HTML, with the only difference being the value of 'marker-attachment' on the list:</p>
<pre>
<ul>
<li>english one
<li dir=rtl>OWT WERBEH
<li>english three
<li dir=rtl>RUOF WERBEH
</ul></pre>
<table class=data style="width: 35em;">
<thead>
<tr>
<th>list-item
<th>list-container
<tbody>
<tr>
<td style="border-right: thin solid">
<ul>
<li>english one
<li dir=rtl>OWT WERBEH
<li>english three
<li dir=rtl>RUOF WERBEH
</ul>
<td>
<ul>
<li>english one
<li>OWT WERBEH
<li>english three
<li>RUOF WERBEH
</ul>
</table>
</div>
<!-- ===================================================================== -->
<h2 id='counter-style'>
Defining Custom Counter Styles: the ''@counter-style'' rule</h2>
<p>CSS 2.1 defined a handful of useful counter styles based on the styles that
HTML traditionally allowed on ordered and unordered lists. This tiny set, though,
is quite inadequate for modern web pages; displaying an ordered list with markers
based on the latin alphabet while the content is Arabic seems quite incongruous!</p>
<p>Unfortunately, the set of potentially useful list styles is too large to
specify ahead of time - the world contains thousands of languages and hundreds
of scripts, not to mention the near-infinite stylistic variations found on the
web that go beyond mere languaged-based variation. The ''@counter-style'' rule
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
'list-style-type' property or in the ''counter()'' and ''counters()'' functions,
exactly like the Complex Counter Styles in CSS.</p>
<p>A <dfn>counter style</dfn> defines how to construct the representation of a
counter value. Counter styles are composed of:</p>
<ul>
<li>a <dfn title='counter-name'>name</dfn>, to identify the style</li>
<li>an <dfn title='counter-algorithm'>algorithm</dfn> that transforms counter
values into a string representation</li>
<li>a <dfn title='counter-negative'>negative sign</dfn>, which is prepended or
appended to the representation of a negative counter value</li>
<li>a <dfn title='counter-prefix'>prefix</dfn>, to prepend to the representation</li>
<li>a <dfn title='counter-suffix'>suffix</dfn>, to append to the representation</li>
<li>an <dfn title='counter-upper-bound'>upper</dfn> and
<dfn title='counter-lower-bound'>lower range bound</dfn>, to specify the
(inclusive) range that the counter style can handle</li>
<li>and a <dfn 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</li>
</ul>
<p>The algorithm is usually specified implicitly by a combination of the ''type'',
''glyphs'', and ''additive-glyphs'' properties, but some counter styles
instead have their algorithm explicitly defined in the
<a href='#predefined-counters'>Complex Counter Styles</a> section.</p>
<p>When asked to <i title='generate-a-counter'>generate a counter representation</i>
using a particular counter style for a particular counter value, follow these steps:</p>
<ol>
<li>If the counter value is less than the <i title='counter-lower-bound'>lower bound</i>
or greater than the <i title='counter-upper-bound'>upper bound</i> of the counter
style, exit this algorithm and instead <i title='generate-a-counter'>generate a counter representation</i>
using the counter style's fallback style and the same counter value.</li>
<li>If the counter value is negative, set the <var>negative</var> flag and
run the rest of this algorithm with the counter value set to its absolute value instead.</li>
<li>Using the counter value and the <i title='counter-algorithm'>counter algorithm</i>
for the counter style, generate an initial representation for the counter value.</li>
<li>If the <var>negative</var> flag is set, wrap the initial representation in the
counter style's <i title='counter-negative'>negative sign</i>, as specified in
the section for the <a href='#counter-style-negative'>negative descriptor</a>.</li>
<li>Return the representation.</li>
</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 computed value of the 'contents' 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.</p>
<p>The general form of an ''@counter-style'' rule is:</p>
<pre>
@counter-style <i><counter-style-name></i> {
[ descriptor: value; ]+
}
</pre>
<p>Each @counter-style 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 @counter-style 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 @counter-style rule, only the last specified value
is used; all prior values for that descriptor must be ignored.</p>
<p>This at-rule conforms with the forward-compatible parsing requirement of CSS; parsers may ignore these rules without error. Any descriptors that are not recognized or implemented by a given user agent must be ignored. The <i><counter-style-name></i> must be be a valid identifier and must not be "decimal", "default", "inherit", "initial", "inside", "none", or "outside"; otherwise the @counter-style is invalid and must be ignored.</p>
<h3 id='counter-style-type'>
Counter algorithms: the 'type' descriptor</h3>
<table class='descdef'>
<tr>
<th>Name:
<td><dfn id="descdef-type">type</dfn>
<tr>
<th>Value:
<td>repeating | numeric | alphabetic | symbolic | additive | <span class=nobr>[non-repeating <integer>?]</span> | <span class=nobr>[ override <counter-style-name> ]</span>
<tr>
<th>Initial:
<td>symbolic
</table>
<p>The 'type' descriptor specifies which algorithm will be used to construct
the counter's representation based on the counter value. For example,
''repeating'' type counter styles just cycle through their glyphs repeatedly,
while <i>numeric</i> type counter styles interpret their glyphs as digits and
build their representation accordingly. The types are defined as follows:</p>
<h4>
repeating</h4>
<p>If the type is <a href=#repeating>repeating</a>, the 'glyphs' descriptor must contain
at least one <i>counter glyph</i>. This type is defined over all counter
values.</p>
<p>The <i>repeating</i> counter type cycles repeatedly through its provided
glyphs, looping back to the beginning when it reaches the end of the
list, similar to the default <i>disc</i> counter style. It can be used for
simple bullets (just provide a single <i>counter glyph</i>), or for cycling
through multiple bullets. The first <i>counter glyph</i> is used as the
representation of the value 1, the second <i>counter glyph</i> (if it exists)
is used as the representation of the value 2, etc.</p>
<p>In general, if there are <var>length</var> <i>counter glyphs</i> and
a representation is being constructed for the value <var>value</var>,
the representation is the <i>counter glyph</i> at index
(<var>value</var> mod <var>length</var>) of the list of <i>counter glyph</i>s
(0-indexed).</p>
<div class=example>
<p>A "triangle bullet" counter style can be defined as:</p>
<pre>
@counter-style <dfn>triangle</dfn> {
type: repeating;
glyphs: '▶';
suffix: '';
}
</pre>
<p>It will then produce lists that look like:</p>
<pre>
▶ One
▶ Two
▶ Three
</pre>
</div>
<h4>
numeric</h4>
<p>If the type is <a href=#numeric>numeric</a>, the 'glyphs' descriptor must contain at
least two <i>counter glyph</i>s. This type is defined over all counter
values.</p>
<p>The <i>numeric</i> counter type cycles interprets the list of
<i>counter glyph</i>s as digits to a number system, similar to the default
<i>decimal</i> counter style. The first <i>counter glyph</i> in the list is
interpreted as the digit 0, the second as the digit 1, and so on. If there
are <var>length</var> <i>counter glyph</i>s, the representation is a base
<var>length</var> number using the <i>counter glyph</i>s as digits.</p>
<p>To construct the representation, run the following algorithm. Let
<var>length</var> be the length of the list of <i>counter glyphs</i>,
<var>value</var> initially be the counter value, <var>S</var>
initially be the empty string, <var>negative</var> be a boolean flag
that is initially false, and <var>glyph(n)</var> be the nth
<i>counter glyph</i> in the list of <i>counter glyph</i>s (0-indexed).</p>
<ol>
<li>If <var>value</var> is 0, append <var>glyph(0)</var> to
<var>S</var> and return <var>S</var>.</li>
<li>While <var>value</var> is not equal to 0:
<ol>
<li>Prepend <var>glyph( <var>value</var> mod <var>length</var> )</var>
to <var>S</var>.</li>