-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview.bs
1453 lines (1200 loc) · 56.3 KB
/
Overview.bs
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
<pre class='metadata'>
Title: CSS Lists Module Level 3
Shortname: css-lists
Level: 3
Group: CSSWG
Status: ED
Work Status: Exploring
ED: https://drafts.csswg.org/css-lists-3/
TR: https://www.w3.org/TR/css-lists-3/
Editor: Tab Atkins, Google, http://xanthir.com/contact/, w3cid 42199
Former Editor: Ian Hickson, Google, ian@hixie.ch
Former Editor: Tantek Çelı̇k, Formerly of Microsoft, tantekc@microsoft.com
Previous Version: https://www.w3.org/TR/2014/WD-css-lists-3-20140320/
Previous Version: https://www.w3.org/TR/2011/WD-css3-lists-20110524/
!Contributors: Simon Montagu, AOL-TW/Netscape, <a href="mailto:smontagu@netscape.com">smontagu@netscape.com</a>
!Contributors: Daniel Yacob, <a href="mailto:yacob@geez.org">yacob@geez.org</a>
!Contributors: Christopher Hoess, <a href="mailto:choess@stwing.upenn.edu">choess@stwing.upenn.edu</a>
!Contributors: Daniel Glazman, AOL-TW/Netscape, <a href="mailto:glazman@netscape.com">glazman@netscape.com</a>
Abstract: This draft contains the features of CSS level 3 relating to list styling. It includes and extends the functionality of CSS level 2 [[!CSS21]]. The main extensions compared to level 2 are a pseudo-element representing the list marker, and some new ways to position markers.
Warning: not ready
</pre>
<pre class='link-defaults'>
spec:css-pseudo-4; type:selector; text:::before
</pre>
<h2 id='intro'>
Introduction</h2>
This specification defines the ''::marker'' pseudo-element,
the ''list-item'' 'display' value that generates markers,
and several properties controlling the placement and styling of markers.
It also defines <a>counters</a>,
which are special numerical objects
often used to generate the default contents of markers.
<div class="example">
For instance, the following example illustrates
how markers can be used to add parentheses around each numbered list item:
<xmp highlight=html>
<style>
li::marker { content: "(" counter(list-item, lower-roman) ")"; }
li { display: list-item; }
</style>
<ol>
<li>This is the first item.
<li>This is the second item.
<li>This is the third item.
</ol>
</xmp>
It should produce something like this:
<pre>
(i) This is the first item.
(ii) This is the second item.
(iii) This is the third item.
</pre>
Note: Note that this example is far more verbose than is usually needed in HTML,
as the UA default style sheet takes care of most of the necessary styling.
</div>
With descendant selectors and child selectors,
it's possible to specify different marker types depending on the depth of embedded lists.
<h2 id='declaring-a-list-item'>
Declaring a List Item</h2>
A <dfn export>list item</dfn> is any element with its 'display' property set to ''list-item''.
<a>List items</a> generate ''::marker'' pseudo-elements;
no other elements do.
Additionally, <a>list items</a> automatically increment the special ''list-item'' <a>counter</a>.
Unless the 'counter-increment' property manually specifies a different increment for the ''list-item'' <a>counter</a>,
it must be incremented by 1 on every <a>list item</a>,
at the same time that <a>counters</a> are normally incremented.
(This has no effect on the values of the 'counter-*' properties.)
If a <a>list item</a> generates an <a>inline box</a>,
such as through ''display: inline list-item'',
the ''outside'' value of 'list-style-position'
must compute to ''inside'' on the element.
<!--
██ ██ ███ ████████ ██ ██ ████████ ████████ ██████
███ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ███ ██ ██ ██ ████████ █████ ██████ ████████ ██████
██ ██ █████████ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ████████ ██ ██ ██████
-->
<h2 id='markers'>
Markers</h2>
The defining feature of a <a>list item</a> is its <dfn export>marker</dfn>,
a symbol or ordinal that helps denote the beginning of each <a>list item</a> in a list.
<h3 id='marker-pseudo'>
The ''::marker'' Pseudo-Element</h3>
The ''::marker'' pseudo-element is automatically generated by a <a>list item</a>,
and is automatically filled with content
according to the <a>list item’s</a> 'list-style' property
(or its subproperties).
The ''::marker'' pseudo-element is generated as the first child of the <a>list item</a>,
before the ''::before'' pseudo-element
(if that exists on the element).
''::marker''s are <a>inline</a> by default,
tho 'list-style-position' can cause them become <a>absolutely positioned</a>.
The ''::marker'' pseudo-element only exists on <a>list items</a>.
On any other element,
the ''::marker'' pseudo-element's 'content' property must compute to ''content/none'',
which suppresses its creation.
Only a limited set of properties can be used on the ''::marker'' pseudo-element.
This list is defined in [[css-pseudo-4#marker-pseudo]].
<div class="example">
In this example, markers are used to number paragraphs that are designated as "notes":
<xmp highlight=html>
<style>
p { margin-left: 12 em; }
p.note {
display: list-item;
counter-increment: note-counter;
}
p.note::marker {
content: "Note " counter(note-counter) ":";
text-align: left;
width: 10em;
}
</style>
<p>This is the first paragraph in this document.
<p class="note">This is a very short document.
<p>This is the end.
</xmp>
It should render something like this:
<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">
By using the ''::marker'' 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:
<xmp highlight=html>
<style>
p { margin-left: 8em } /* Make space for counters */
li { list-style-type: lower-roman; }
li::marker { color: blue; font-weight:bold; }
</style>
<p>This is a long preceding paragraph ...
<ol>
<li>This is the first item.
<li>This is the second item.
<li>This is the third item.
</ol>
<p>This is a long following paragraph ...
</xmp>
The preceding document should render something like this:
<pre>
This is a long preceding
paragraph ...
<span style=color:blue;font-weight:bold;>i.</span> This is the first item.
<span style=color:blue;font-weight:bold;>ii.</span> This is the second item.
<span style=color:blue;font-weight:bold;>iii.</span> This is the third item.
This is a long following
paragraph ...
</pre>
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.
</div>
<h3 id='content-property'>
Generating The ''::marker'' Boxes</h3>
The ''::marker'' pseudo-element
generates different contents
(always <a>anonymous</a>)
according to the 'list-style-image' and 'list-style-type' properties
on its <a>originating element</a>,
depending on the first of these conditions that is true:
<dl class=switch>
<dt>'list-style-image' is a <a>valid image</a>
<dd>
The contents of the ''::marker''
are an <a>anonymous</a> <a>inline</a> <a>replaced element</a>
representing the <<image>>,
followed by a <a>text run</a> containing a single space (U+0020 SPACE).
<dt>'list-style-type' is a <<string>>
<dd>
The contents of the ''::marker''
are a <a>text run</a> containing the <<string>>.
<dt>'list-style-type' is a <<counter-style>>
<dd>
The contents of the ''::marker''
are a <a>text run</a> containing the ''@counter-style/prefix'' of the <<counter-style>>,
followed by the result of <a lt="generate a counter representation">generating a counter representation</a>
for the <<counter-style>>
and the value of the <css>list-item</css> counter on the <a>originating element</a>,
followed by a <a>text run</a> containing the ''@counter-style/suffix'' of the <<counter-style>>.
<dt>otherwise
<dd>
The ''::marker'' has no contents.
</dl>
<!--
██ ██████ ████ ██ ██ ███ ██████ ████████
██ ██ ██ ██ ███ ███ ██ ██ ██ ██ ██
██ ██ ██ ████ ████ ██ ██ ██ ██
██ ███████ ██████ ███████ ██ ██ ███ ██ ██ ██ ██ ████ ██████
██ ██ ██ ██ ██ █████████ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
████████ ██████ ████ ██ ██ ██ ██ ██████ ████████
-->
<h3 id='image-markers'>
Image Markers: the 'list-style-image' property</h3>
<pre class="propdef">
Name: list-style-image
Value: <<image>> | none
Initial: none
Applies to: <a>list items</a>
Inherited: yes
Percentages: n/a
Computed value: computed value of the <<image>>, or ''list-style-image/none''
Animation type: discrete
</pre>
The 'list-style-image' property specifies an image
that will be used to fill the ''::marker'' pseudo-element.
The values are as follows:
<dl dfn-type="value" dfn-for="list-style-image">
<dt><dfn><<image>></dfn>
<dd>
Specifies that the ''::marker'' for the <a>list item</a>
should show the specified <<image>>.
If the <<image>> ends up being an <a>invalid image</a>,
this value instead does nothing
(like ''list-style-image/none'').
<dt><dfn>none</dfn>
<dd>
Does nothing.
Instead, 'list-style-type' will be consulted
to determine how to fill the ''::marker''.
</dl>
<div class="example">
The following example sets the marker at the beginning of each list item to
be the image "ellipse.png".
<pre highlight=css>li { list-style-image: url("http://www.example.com/ellipse.png") }</pre>
</div>
<!--
██ ██████ ████████ ██ ██ ████████ ████████
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ████ ██ ██ ██
██ ███████ ██████ ███████ ██ ██ ████████ ██████
██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
████████ ██████ ██ ██ ██ ████████
-->
<h3 id='text-markers'>
Text-based Markers: the 'list-style-type' property</h3>
<pre class="propdef">
Name: list-style-type
Value: <<counter-style>> | <<string>> | none
Initial: disc
Applies to: <a>list items</a>
Inherited: yes
Percentages: n/a
Computed value: specified value
Animation type: discrete
</pre>
When the value of 'list-style-image' is ''list-style-image/none''
or an <a>invalid image</a>,
the 'list-style-type' property instead specifies how to fill the ''::marker''.
The values are as follows:
<dl dfn-type="value" dfn-for="list-style-type">
<dt><dfn><<counter-style>></dfn>
<dd>
The ''::marker''‘s contents will be generated
according to the rules for that <a>counter style</a>. [[!CSS-COUNTER-STYLES-3]]
<dt><dfn><<string>></dfn>
<dd>
The ''::marker'' will contain the <<string>>.
<dt><dfn>none</dfn>
<dd>
The ''::marker'' will not contain anything.
</dl>
<div class='example'>
The following examples illustrate how to set markers to various values:
<pre highlight=css>
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
(defined in the Counter Styles specification [[CSS-COUNTER-STYLES]]) */
ul { list-style-type: symbols(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. */
</pre>
</div>
<!--
██ ██████ ████████ ███████ ██████ ████ ████████ ████ ███████ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██
██ ███████ ██████ ███████ ████████ ██ ██ ██████ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███
████████ ██████ ██ ███████ ██████ ████ ██ ████ ███████ ██ ██
-->
<h3 id='list-style-position-property'>
Positioning Markers: The 'list-style-position' property</h3>
<pre class="propdef">
Name: list-style-position
Value: inside | outside
Initial: outside
Applies to: <a>list items</a>
Inherited: yes
Percentages: n/a
Computed value: keyword, but see prose
Animation type: discrete
</pre>
This property dictates whether the ''::marker'' is rendered inline,
or positioned just outside of the <a>list item</a>.
The values are as follows:
<dl dfn-type=value dfn-for=list-style-position>
<dt><dfn>inside</dfn>
<dd>
No special effect.
(The ''::marker'' is an inline element at the start of the <a>list item's</a> contents.)
<dt><dfn id='list-style-position-outside'>outside</dfn>
<dd>
The 'position' property on the marker computes to ''marker''.
Additionally, the base directionality of the marker
(used as an input to the bidi resolution algorithm)
must be taken from the marker's <a>marker positioning reference element</a>.
If the <a>list item</a> is <a>inline</a>,
this value instead computes to ''inside''.
</dl>
<div class=example>
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>
The above example may be formatted as:
<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>
<!--
██ ████ ██████ ████████ ██████ ████████ ██ ██ ██ ████████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ████ ██ ██
██ ██ ██████ ██ ███████ ██████ ██ ██ ██ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
████████ ████ ██████ ██ ██████ ██ ██ ████████ ████████
-->
<h3 id='list-style-property'>
Styling Markers: the 'list-style' shorthand property</h3>
<pre class='propdef shorthand'>
Name: list-style
Value: <<'list-style-type'>> || <<'list-style-position'>> || <<'list-style-image'>>
Applies to: <a>list items</a>
</pre>
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.
<div class="example">
For example:
<pre highlight=css>
ul { list-style: upper-roman inside } /* Any UL */
ul ul { list-style: circle outside } /* Any UL child of a UL */
</pre>
</div>
Using a value of <css>none</css> in the shorthand is potentially ambiguous,
as <css>none</css> is a valid value for both 'list-style-image' and 'list-style-type'.
To resolve this ambiguity,
a value of <css>none</css> in the shorthand must be applied to whichever of the two properties aren't otherwise set by the shorthand.
<div class='example'>
<pre highlight=css>
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>
<div class=example highlight=css>
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:
<pre>
ol.alpha li { list-style: lower-alpha; }
ul li { list-style: disc; }
</pre>
The above won't work as expected.
If you nest a <{ul}> into an <a element lt="ol">ol class=alpha</a>,
the first rule's specificity will make the <{ul}>’s list items use the lower-alpha style.
<pre>
ol.alpha > li { list-style: lower-alpha; }
ul > li { list-style: disc; }
</pre>
These work as intended.
<pre>
ol.alpha { list-style: lower-alpha; }
ul { list-style: disc; }
</pre>
These are even better,
since inheritance will transfer the 'list-style' value to the list items.
</div>
<!--
████████ ███████ ██████ ████ ████████ ████ ███████ ██ ██ ████ ██ ██ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ███ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
████████ ██ ██ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ███ ██ ██
██ ███████ ██████ ████ ██ ████ ███████ ██ ██ ████ ██ ██ ██████
-->
<h2 id='positioning'>
Marker Positioning</h2>
<p class='issue'><strong>
This section is not ready for implementation.
It is an unreviewed rough draft that hasn't even been properly checked for Web-compatibility.
Feel free to send feedback, but DON'T USE THIS PART OF THE SPEC.</strong>
<h3 id='position-marker'>
The ''marker'' value for 'position'</h3>
This section introduces a new positioning scheme,
designed to model the way in which ''list-style-position:outside'' list markers were traditionally positioned in CSS 2.1.
Outside list markers now have their positioning defined in terms of this new value.
The new positioning scheme defined in this section can be used on all elements,
not just ''::marker'' pseudo-elements.
For example, this can be used to position explicit elements serving as markers in a legal document,
so that the list item has a marker whose value is guaranteed to be correct regardless of whether the CSS is applied
(often a requirement in legal documents),
but which is positioned like a native CSS marker.
<pre class="propdef partial">
Name: position
New values: marker
Computed value: see prose, otherwise same as normal
</pre>
The <dfn value for=position>marker</dfn> value for 'position' depends on the element it is set on having a <a>list item</a> ancestor.
If the specified value of 'position' is ''position/marker''
and the element does not have a <a>list item</a> ancestor,
'position' must compute to ''position/relative'' on the element.
An element with ''position:marker'' counts as <a>absolutely positioned</a>.
To calculate the marker's position, we must first define a few terms:
<dl>
<dt><dfn>ancestor list item</dfn>
<dd>The <a>ancestor list item</a> is the marker's nearest list item ancestor element.
<dt><dfn>marker positioning reference element</dfn>
<dd>
If the <a>ancestor list item</a> has ''marker-side:list-item'',
the <a>marker positioning reference element</a> is the <a>ancestor list item</a>.
Otherwise, if the <a>ancestor list item</a> has ''marker-side:list-container'' and has a parent element,
the <a>marker positioning reference element</a> is that parent.
Otherwise, the <a>marker positioning reference element</a> is the <a>ancestor list item</a>.
<dt><dfn>list item positioning edge</dfn>
<dd>
The border edge of the <a>ancestor list item</a> corresponding to the "inline-start" edge of the <a>marker positioning reference element</a>.
<dt><dfn>marker positioning edge</dfn>
<dd>
The outer edge of the marker that's on the opposite side from the <a>list item positioning edge</a>.
For example, if the <a>list item positioning edge</a> ended up being the left border edge of the <a>ancestor list item</a>,
the <a>marker positioning edge</a> would be the right margin edge of the marker.
</dl>
The marker's position in the <a>ancestor list item</a>’s block axis
is calculated according to the <a href="https://www.w3.org/TR/CSS21/visuren.html#normal-flow">normal flow</a>.
The marker's position in the <a>ancestor list item's</a> inline axis must be set such that
the <a>marker positioning edge</a> is flush with the <a>list item positioning edge</a>.
Note: The purpose of this somewhat convoluted definition is to position the marker flush against its list item,
and then when "marker-side: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 of the list container and still ensure their markers are visible.
And on top of all that,
do something reasonable in the face of potentially differing writing-modes
on the marker, list item, and container.
All elements or pseudo-elements with ''position:marker''
that share a common <a>ancestor list item</a>
are known as <dfn lt='associated marker'>markers associated with that list item</dfn>.
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.
<div class='example'>
''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:
<pre highlight=html>
<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><span class='marker'>(2)</span> the term “individual” means a citizen...
</ol>
<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...
<li><span class='marker'>(2)</span> required under section 552 of this title;
</ol>
</ol>
</pre>
The preceding document should render something like this:
<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...
(2) required under section 552 of this title;
</pre>
Importantly, even if the stylesheet is unavailable,
the list markers will appear the same
(though they will be positioned slightly differently),
so other documents can refer to those list markers
and be confident that the reference will always be resolvable.
</div>
<!--
██ ██ ███ ████████ ██ ██ ████████ ████████ ██████ ████ ████████ ████████
███ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ███ ██ ██ ██ ████████ █████ ██████ ████████ ███████ ██████ ██ ██ ██ ██████
██ ██ █████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ████████ ██ ██ ██████ ████ ████████ ████████
-->
<h3 id='marker-side'>
The 'marker-side' property</h3>
By default, elements or ''::marker'' 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-side' 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.
<pre class='propdef'>
Name: marker-side
Value: list-item | list-container
Initial: list-item
Applies to: <a>list items</a>
Inherited: yes
Percentages: n/a
Computed value: specified keyword
Animation type: discrete
</pre>
<dl dfn-type=value dfn-for=marker-side>
<dt><dfn>list-item</dfn>
<dd>
Any <a>associated markers</a> base their positioning off of the directionality of the list item.
<dt><dfn>list-container</dfn>
<dd>
The <a>associated markers</a> 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>.
</dl>
<div class='example'>
Here is an example of the effect that 'marker-side' can have on a list.
Both of the following example renderings are generated from the following HTML,
with the only difference being the value of 'marker-side' on the list:
<pre highlight=html>
<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">
<pre>
* english one
OWT WERBEH *
* english three
RUOF WERBEH *</pre>
<td>
<pre>
* english one
* OWT WERBEH
* english three
* RUOF WERBEH</pre>
</table>
</div>
<!--
██████ ███████ ██ ██ ██ ██ ████████ ████████ ████████ ██████
██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ████████ ██████
██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██
██████ ███████ ███████ ██ ██ ██ ████████ ██ ██ ██████
-->
<h2 id='auto-numbering'>
Automatic Numbering With Counters</h2>
A <dfn export>counter</dfn> is a special concept
used, among other things, to automatically number list items in CSS.
Every element has a collection of zero or more counters,
which are inherited through the document tree in a way similar to inherited property values.
They are created and manipulated with the 'counter-increment', 'counter-set' and 'counter-reset' properties,
and used with the ''counter()'' and ''counters()'' functions.
Counters have a name,
an integer value,
a creator element,
and possibly another counter nested inside themselves.
<h3 id='counter-properties'>
Manipulating Counters: the 'counter-increment', 'counter-set' and 'counter-reset' properties</h2>
<pre class="propdef">
Name: counter-reset
Value: [ <<custom-ident>> <<integer>>? ]+ | none
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: the keyword ''counter-reset/none'' or a list, each item an identifier paired with an integer
Animation type: by computed value type
</pre>
<p class=all-media>User Agents are expected to support this property on all media, including non-visual ones.</p>
The 'counter-reset' property <a lt="create a new counter">creates new counters</a> on an element.
Its values are defined as follows:
<dl dfn-type=value dfn-for=counter-reset>
<dt><dfn>none</dfn>
<dd>
This element does not create any new counters.
<dt><dfn><<custom-ident>> <<integer>>?</dfn>
<dd>
The element <a lt="create a new counter">creates one or more new counters</a>.
Each <<custom-ident>> names a new counter to be created.
If an <<integer>> is provided after an <<custom-ident>>,
the starting value of the new counter is that integer.
Otherwise, the starting value of the new counter is ''0''.
Implementations may have implementation-specific limits
on the maximum or minimum value of a counter.
If an increment would push the counter's value beyond these limits,
the increment must be ignored,
and the counter's value remain unchanged.
</dl>
<pre class='propdef'>
Name: counter-set
Value: [ <<custom-ident>> <<integer>>? ]+ | none
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: the keyword ''counter-reset/none'' or a list, each item an identifier paired with an integer
Animation type: by computed value type
</pre>
<p class=all-media>User Agents are expected to support this property on all media, including non-visual ones.</p>
<pre class='propdef'>
Name: counter-increment
Value: [ <<custom-ident>> <<integer>>? ]+ | none
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: the keyword ''counter-reset/none'' or a list, each item an identifier paired with an integer
Animation type: by computed value type
</pre>
<p class=all-media>User Agents are expected to support this property on all media, including non-visual ones.</p>
The 'counter-set' and 'counter-increment' properties
manipulate the value of existing counters.
They only create new counters if there is no counter of the given name on the element yet.
Their values are defined as follows:
<dl dfn-type=value dfn-for="counter-set counter-increment">
<dt><dfn>none</dfn>
<dd>
This element does not alter the value of any counters.
<dt><dfn><<custom-ident>> <<integer>>?</dfn>
<dd>
The element alters the value of one or more counters on it.
If there is not currently a counter of the given name on the element,
the element <a lt="create a new counter">creates a new counter</a> of the given name
with a starting value of ''0''
(though it may then immediately set or increment that value to something different).
If an <<integer>> is provided after an <<custom-ident>>,
it sets the innermost counter of the given name's value to that integer (for 'counter-set')
or increments the value of the innermost counter of the given name by that integer (for 'counter-increment').
Otherwise,
the innermost counter of the given name's value is set to ''0'' (for 'counter-set')
or incremented by ''1'' (for 'counter-increment').
</dl>
<div class="example">
<p>This example shows a way to number chapters and sections with "Chapter 1", "1.1", "1.2", etc.
<pre highlight=css>
h1::before {
content: "Chapter " counter(chapter) ". ";
counter-increment: chapter; /* Add 1 to chapter */
counter-reset: section; /* Set section to 0 */
}
h2::before {
content: counter(chapter) "." counter(section) " ";
counter-increment: section;
}
</pre>
</div>
Inheriting counters must be done <em>before</em> resetting counters,
which must be done <em>before</em> setting counters,
which must be done <em>before</em> incrementing counters,
which must be done <em>before</em> using counters
(for example, in the 'content' property).
<div class='note' highlight=css>
The counter properties follow the cascading rules as normal.
Thus, due to cascading, the following style sheet:
<div class='example'>
<pre>
h1 { counter-reset: section -1 }
h1 { counter-reset: imagenum 99 }
</pre>
</div>
will only reset ''imagenum''.
To reset both counters,
they have to be specified together:
<div class='example'>
<pre>H1 { counter-reset: section -1 imagenum 99 }</pre>
</div>
The same principles apply to the 'counter-set' and 'counter-increment' properties.
</div>
<h3 id="creating-counters">
Creating and Inheriting Counters</h3>
Every element has a (possibly empty) set of counters.
Like many other CSS values,
an element can inherit counters from another element.
However, unlike other CSS values,
the method that counters are inherited is somewhat complex.
A counter and its value are inherited <em>separately</em>,
possibly from different elements.
If an element has a previous sibling,
it must inherit all of the sibling's counters.
Otherwise, if the element has a parent,
it must inherit all of the parent's counters.
Otherwise, the element must have an empty set of counters.
The element then inherits counter <em>values</em>
from the immediately preceding element <strong>in document order</strong>.
This must be done by examining the set of counters that the immediately preceding element has,
and, for every counter that exists in both the element's set and the preceding element's set,
giving the element's counter the same value.
(If an element is the first element in the document,
and thus has no immediately preceding element,
it also doesn't have a parent or a previous sibling,
and thus no counters to begin with.)
<div class='example' id='counter-inheritance-example'>
Take the following code as an example:
<pre highlight=html>
<ul style='counter-reset: example 0;'>
<b class='foo'><li id='foo' style='counter-increment: example;'></b>
foo
<b class='bar'><div id='bar' style='counter-increment: example;'>bar</div></b>
</li>
<b class='baz'><li id='baz'></b>
baz
</li>
</ul>
</pre>
Recall that "in document order" turns a document tree into an ordered list,
where an element comes before its children,
and its children come before its next sibling.
In other words,
for a language like HTML,
its the order in which the parser encounters start tags as it reads the document.
In here, the <{ul}> element establishes a new counter named "example",
and sets its value to 0.
The <b class='foo'>"foo"</b> element, being the first child of the <{ul}>,
inherits this counter.
Its parent is also its immediately preceding element in document order,
so it inherits the value 0 with it,
and then immediately increments the value to 1.
The same happens with the <b class='bar'>"bar"</b> element.
It inherits the "example" counter from <b class='foo'>"foo"</b>,
and inherits the value 1 from it as well
and increments it to 2.
However, the <b class='baz'>"baz"</b> element is a bit different.
It inherits the "example" counter from the <b class='foo'>"foo"</b> element,
its previous sibling.
However, rather than inheriting the value 1 from <b class='foo'>"foo"</b> along with the counter,
in inherits the value 2 from <b class='bar'>"bar"</b>, the previous element in document order.
This behavior allows a single counter to be used throughout a document,
continuously incrementing,
without the author having to worry about the nested structure of their document.
</div>
<style>
#counter-inheritance-example b.foo { color: hsl(0, 80%, 40%); }
#counter-inheritance-example b.bar { color: hsl(120, 80%, 30%); }
#counter-inheritance-example b.baz { color: hsl(240, 80%, 50%); }
</style>
Elements can create additional counters on themselves,
which can then be passed onto siblings or children.
To <dfn>create a new counter</dfn>,
specify an element that's creating it,
a name,
and a starting value.
The effect depends on what other counters of that name exist on the element:
<ul>
<li>
If no counters of that name exist on the element,
create a new counter with that name on the element.