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
3641 lines (2816 loc) · 127 KB
/
Overview.html
File metadata and controls
3641 lines (2816 loc) · 127 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 content="text/html; charset=utf-8" http-equiv=Content-Type>
<link href="http://dev.w3.org/csswg/default.css" rel=stylesheet
type="text/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 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 Lists and Counters Module Level 3</h1>
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 17 January
2012</h2>
<dl>
<dt>This version:
<dd><!--<a href="http://www.w3.org/TR/2012/WD-css3-lists-20120117">http://www.w3.org/TR/2012/WD-css3-lists-20120117</a></dd>-->
<a
href="http://dev.w3.org/csswg/css3-lists/">http://dev.w3.org/csswg/css3-lists/</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-lists/">http://www.w3.org/TR/css3-lists/</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>Editor:
<dd><a href="http://www.xanthir.com/contact">Tab Atkins Jr.</a>, Google
Inc.
<dt>Previous Editors:</dt>
<!-- in the order tantek requested -->
<dd>Ian Hickson, <a href="mailto:ian@hixie.ch">ian@hixie.ch</a>
<dd><span lang=tr>Tantek Çelı̇k</span>, Microsoft
Corporation, <a
href="mailto:tantekc@microsoft.com">tantekc@microsoft.com</a>
<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>Daniel Yacob, <a href="mailto:yacob@geez.org">yacob@geez.org</a>
<dd>Christopher Hoess, <a
href="mailto:choess@stwing.upenn.edu">choess@stwing.upenn.edu</a>
<dd>Daniel Glazman, AOL-TW/Netscape, <a
href="mailto:glazman@netscape.com">glazman@netscape.com</a>
</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/"><acronym
title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><acronym
title="Massachusetts Institute of Technology">MIT</acronym></a>, <a
href="http://www.ercim.eu/"><acronym
title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></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>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 <a
href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>, which builds
on CSS level 1 <a href="#CSS1"
rel=biblioentry>[CSS1]<!--{{CSS1}}--></a>. 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.
<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=%5Bcss3-lists%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
“css3-lists” in the subject, preferably like this:
“[<!---->css3-lists<!---->] <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-->
<h2 class="no-num no-toc" id=contents> Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#introduction"><span class=secno>1. </span> Introduction</a>
<li><a href="#declaring-a-list-item"><span class=secno>2. </span>
Declaring a List Item</a>
<li><a href="#marker-content"><span class=secno>3. </span> Marker Content:
The ‘<code class=property>list-style-image</code>’ and
‘<code class=property>list-style-type</code>’ properties</a>
<li><a href="#list-style-position-property"><span class=secno>4. </span>
Marker Position: The ‘<code
class=property>list-style-position</code>’ property</a>
<li><a href="#list-style-property"><span class=secno>5. </span> The
‘<code class=property>list-style</code>’ shorthand
property</a>
<li><a href="#marker-pseudo-element"><span class=secno>6. </span> Markers:
The <code class=css>::marker</code> pseudo-element</a>
<ul class=toc>
<li><a href="#content-property"><span class=secno>6.1. </span>
Generating the computed value of the ‘<code
class=property>content</code>’ property</a>
</ul>
<li><a href="#positioning-markers"><span class=secno>7. </span>
Positioning Markers</a>
<ul class=toc>
<li><a href="#position-marker"><span class=secno>7.1. </span> The
‘<code class=css>marker</code>’ value for ‘<code
class=property>position</code>’</a>
<li><a href="#marker-attachment"><span class=secno>7.2. </span> The
‘<code class=property>marker-attachment</code>’
property</a>
</ul>
<li><a href="#counter"><span class=secno>8. </span> Automatic Counters and
Numbering: the ‘<code
class=property>counter-increment</code>’, ‘<code
class=property>counter-set</code>’ and ‘<code
class=property>counter-reset</code>’ properties</a>
<ul class=toc>
<li><a href="#nested-counters"><span class=secno>8.1. </span> Nested
counters and scope</a>
<li><a href="#counters-without-boxes"><span class=secno>8.2. </span>
Counters in elements that do not generate boxes</a>
</ul>
<li><a href="#counter-function"><span class=secno>9. </span> Printing
Counters: the ‘<code class=css>counter()</code>’ and
‘<code class=css>counters()</code>’ functions</a>
<li><a href="#counter-style"><span class=secno>10. </span> Defining Custom
Counter Styles: the ‘<code class=css>@counter-style</code>’
rule</a>
<ul class=toc>
<li><a href="#counter-style-type"><span class=secno>10.1. </span>
Counter algorithms: the ‘<code class=property>type</code>’
descriptor</a>
<ul class=toc>
<li><a href="#repeating"><span class=secno>10.1.1. </span>
repeating</a>
<li><a href="#numeric"><span class=secno>10.1.2. </span> numeric</a>
<li><a href="#alphabetic"><span class=secno>10.1.3. </span>
alphabetic</a>
<li><a href="#symbolic"><span class=secno>10.1.4. </span> symbolic</a>
<li><a href="#non-repeating"><span class=secno>10.1.5. </span>
non-repeating</a>
<li><a href="#additive"><span class=secno>10.1.6. </span> additive</a>
<li><a href="#override"><span class=secno>10.1.7. </span> override</a>
</ul>
<li><a href="#counter-style-negative"><span class=secno>10.2. </span>
Formatting negative values: the ‘<code
class=property>negative</code>’ descriptor</a>
<li><a href="#counter-style-prefix"><span class=secno>10.3. </span>
Symbols before the marker: the ‘<code
class=property>prefix</code>’ descriptor</a>
<li><a href="#counter-style-suffix"><span class=secno>10.4. </span>
Symbols after the marker: the ‘<code
class=property>suffix</code>’ descriptor</a>
<li><a href="#counter-style-range"><span class=secno>10.5. </span>
Limiting the counter scope: the ‘<code
class=property>range</code>’ descriptor</a>
<li><a href="#counter-style-fallback"><span class=secno>10.6. </span>
Defining fallback: the ‘<code
class=property>fallback</code>’ descriptor</a>
<li><a href="#counter-style-symbols"><span class=secno>10.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>11. </span> Defining
Anonymous Counter Styles: the ‘<code
class=css>symbols()</code>’ function</a>
<li><a href="#predefined-counters"><span class=secno>12. </span>
Predefined Counter Styles</a>
<li><a href="#ua-stylesheet"><span class=secno>13. </span> Sample style
sheet for HTML</a>
<li class=no-num><a href="#profiles"> Profiles</a>
<li class=no-num><a href="#acknowledgments"> Acknowledgments</a>
<li class=no-num><a href="#changes"> Changes From CSS2.1</a>
<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=introduction><span class=secno>1. </span> 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>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.
<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 class=issue>A future release of this module will probably include ways
to render tree lists.</p>
<!-- ====================================================================== -->
<h2 id=declaring-a-list-item><span class=secno>2. </span> Declaring a List
Item</h2>
<p>To declare a <dfn id=list-item>list item</dfn>, the ‘<code
class=property>display</code>’property must be set to ‘<code
class=css>list-item</code>’ or ‘<a
href="#inline-list-item"><code
class=css>inline-list-item</code></a>’ (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 ‘<code class=css>list-item</code>’: if the
element doesn't otherwise have a ‘<a href="#counter-increment"><code
class=property>counter-increment</code></a>’ declaration, it must
act as if ‘<code class=css>counter-increment:
list-item</code>’ were specified. (This does not affect the
specified or computed values of the counter properties.)
<p>The ‘<code class=css>list-item</code>’ counter is a real
counter, and can be directly affected using the ‘<a
href="#counter-increment"><code
class=property>counter-increment</code></a>’ and ‘<a
href="#counter-reset"><code class=css>counter-reset</code></a>’
properties. It can also be used in the ‘<code
class=css>counter()</code>’ and ‘<code
class=css>counters()</code>’ functions.
<table class=propdef>
<tbody>
<tr>
<th>Property:
<td>‘<code class=property>display</code>’
<tr>
<th>New Value:
<td><dfn id=inline-list-item>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
</table>
<p>The ‘<a href="#inline-list-item"><code
class=css>inline-list-item</code></a>’ 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 ‘<code class=css>list-item</code>’ counter, as
specified above. Otherwise, this display value is treated identically to
‘<code class=css>inline</code>’.
<p class=note>This display value is silly, and only necessary because we
haven't yet defined ‘<code class=property>display</code>’ 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><span class=secno>3. </span> Marker Content: The
‘<a href="#list-style-image"><code
class=property>list-style-image</code></a>’ and ‘<a
href="#list-style-type"><code
class=property>list-style-type</code></a>’ properties</h2>
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=list-style-image>list-style-image</dfn>
<tr>
<th>Value:
<td><image> | none
<tr>
<th>Initial
<td>none
<tr>
<th>Applies To:
<td><a href="#list-item"><i title="list item">list items</i></a>
<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 ‘<a href="#list-style-type"><code
class=property>list-style-type</code></a>’ 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>If the value ‘<a href="#none"><code
class=css>none</code></a>’ is provided, or the <i><image></i>
doesn't resolve to a valid image, then the default contents are given by
‘<a href="#list-style-type"><code
class=property>list-style-type</code></a>’ instead.
<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>
<tbody>
<tr>
<th>Name:
<td><dfn id=list-style-type>list-style-type</dfn>
<tr>
<th>Value:
<td><string> | <counter-style> | none
<tr>
<th>Initial:
<td>disc
<tr>
<th>Applies To:
<td><a href="#list-item"><i title="list item">list items</i></a>
<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 ‘<a href="#list-style-image"><code
class=property>list-style-image</code></a>’ property is ‘<a
href="#none"><code class=css>none</code></a>’ or not a valid image,
the ‘<a href="#list-style-type"><code
class=property>list-style-type</code></a>’ property must be used to
construct the default contents of a list item's marker; otherwise, the
‘<a href="#list-style-type"><code
class=property>list-style-type</code></a>’ property must be ignored
and have no effect.
<dl>
<dt><string>
<dd>The <code class=css>::marker</code> pseudo-element must use the
provided string as its default contents.
<dt><a href="#ltcounter-style"><i><counter-style></i></a>
<dd>
<p>The <code class=css>::marker</code> pseudo-element's default contents
must be the value of the ‘<code class=css>list-item</code>’
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>
<dt><dfn id=none>none</dfn>
<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 ‘<code class=property>content</code>’ property.
</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 <a href="#ltcounter-style"><i><counter-style></i></a> type is
defined as:
<pre><dfn
id=ltcounter-style><counter-style></dfn> = <identifier> | <symbols-function></pre>
<p>where the <identifier> must be the name of a valid custom counter
style defined with the ‘<code class=css>@counter-style</code>’
rule.</p>
<!-- ====================================================================== -->
<h2 id=list-style-position-property><span class=secno>4. </span> Marker
Position: The ‘<a href="#list-style-position"><code
class=property>list-style-position</code></a>’ property</h2>
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=list-style-position>list-style-position</dfn>
<tr>
<th>Value:
<td>inside | outside
<tr>
<th>Initial:
<td>outside
<tr>
<th>Applies To:
<td><a href="#list-item"><i title="list item">list items</i></a>
<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 <a
href="#list-item"><i>list item</i></a>. Values have the following
meanings:
<dl>
<dt><dfn id=inside>inside</dfn>
<dd>The <code class=css>::marker</code> pseudo-element is a ‘<code
class=css>display:inline</code>’ element placed immediately before
the ‘<code class=css>::before</code>’ pseudo-element in the
<a href="#list-item"><i>list item</i></a>‘<code class=css>s
principle box, after which the element</code>’s content flows. Note
that if there is no inline content, this will create a line box, just as
content in an inline ‘<code class=css>::before</code>’
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.
<dt><dfn id=outside>outside</dfn>
<dd>As ‘<a href="#inside"><code class=css>inside</code></a>’,
plus the ‘<code class=property>position</code>’ property on
the <code class=css>::marker</code> pseudo-element must computer to
‘<code class=css>marker</code>’. The section on the new
‘<code class=property>marker</code>’ value for ‘<code
class=property>position</code>’ 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 <a
href="#marker-positioning-reference-element"><i>marker positioning
reference element</i></a>.
</dl>
<p>Note that a marker is only generated if the computed value of the
‘<code class=property>content</code>’ property for the
element's <code class=css>::marker</code> pseudo-element is not ‘<a
href="#none"><code class=css>none</code></a>’.
<p class=issue>Should I make this always compute to ‘<a
href="#inside"><code class=css>inside</code></a>’ when the list item
is ‘<code class=css>display:inline-list-item</code>’? 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>.
<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><span class=secno>5. </span> The ‘<a
href="#list-style"><code class=property>list-style</code></a>’
shorthand property</h2>
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=list-style>list-style</dfn>
<tr>
<th>Value:
<td><‘<a href="#list-style-type"><code
class=property>list-style-type</code></a>’> || <‘<a
href="#list-style-position"><code
class=property>list-style-position</code></a>’> || <‘<a
href="#list-style-image"><code
class=property>list-style-image</code></a>’>
<tr>
<th>Initial:
<td>see individual properties
<tr>
<th>Applies To:
<td><a href="#list-item"><i title="list item">list items</i></a>
<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 ‘<a href="#list-style"><code
class=property>list-style</code></a>’ property is a shorthand
notation for setting the three properties ‘<a
href="#list-style-type"><code
class=property>list-style-type</code></a>’, ‘<a
href="#list-style-image"><code
class=property>list-style-image</code></a>’, and ‘<a
href="#list-style-position"><code
class=property>list-style-position</code></a>’ at the same place in
the style sheet.
<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 ‘<a href="#none"><code
class=css>none</code></a>’ in the shorthand is potentially
ambiguous, as ‘<a href="#none"><code
class=css>none</code></a>’ is a valid value for both ‘<a
href="#list-style-image"><code
class=property>list-style-image</code></a>’ and ‘<a
href="#list-style-type"><code
class=property>list-style-type</code></a>’. To resolve this
ambiguity, a value of ‘<a href="#none"><code
class=css>none</code></a>’ in the shorthand must be applied to
whichever of the two properties aren't otherwise set by the shorthand.
<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 ‘<a href="#list-style"><code
class=property>list-style</code></a>’ information directly on list
item elements (e.g., LI in HTML), they should do so with care. Consider
the following rules:
<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><span class=secno>6. </span> Markers: The
<code class=css>::marker</code> pseudo-element</h2>
<p>Markers are created by setting an element's ‘<code
class=property>display</code>’ property to ‘<code
class=css>list-item</code>’ or ‘<a
href="#inline-list-item"><code
class=css>inline-list-item</code></a>’. The <code
class=css>::marker</code> pseudo-element is only created if the computed
value of the ‘<code class=property>content</code>’ property
for the pseudo-element is not ‘<a href="#none"><code
class=css>none</code></a>’.
<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 ‘<a href="#list-style-position"><code
class=property>list-style-position</code></a>’ on the list item can
make the marker box positioned, which can have an effect on the computed
value of display.
<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 ‘<code
class=property>margin</code>’ couldn't be adjusted at all on the
marker.</p>
</div>
<!-- ====================================================================== -->
<h3 id=content-property><span class=secno>6.1. </span> Generating the
computed value of the ‘<code class=property>content</code>’