-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathgenerate.src
More file actions
1449 lines (1210 loc) · 51.6 KB
/
generate.src
File metadata and controls
1449 lines (1210 loc) · 51.6 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 PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Generated content, automatic numbering, and lists</title>
</head>
<body>
<h1 align="center">
<a name="generated-text">Generated</a> <span class="index-def"
title="generated content">content</span>, automatic <span
class="index-def" title="automatic numbering">numbering</span>,
and lists</h1>
<p>In some cases, authors may want user agents to render content
that does not come from the <a href="conform.html#doctree">document
tree</a>. One familiar example of this is a numbered list; the author
does not want to list the numbers explicitly, he or she wants the
user agent to generate them automatically. Similarly, authors
may want the user agent to insert the word
"Figure" before the caption of a figure, or "Chapter 7" before the
seventh chapter title. For audio or braille in particular, user agents
should be able to insert these strings.
<p>In CSS2, content may be generated by several mechanisms:</p>
<ul>
<li>The <span class="propinst-content">'content'</span>
property, in conjunction with the :before and :after pseudo-elements.
<li>The <span class="propinst-cue-before">'cue-before'</span>,
<span class="propinst-cue-after">'cue-after'</span>
aural properties (see the chapter
on <a href="aural.html">aural style sheets</a>).
When the <span
class="propinst-content">'content'</span> property is combined with the aural properties
they are rendered in the following order: :before, <span
class="propinst-cue-before">'cue-before'</span>, (<span
class="propinst-pause-before">'pause-before'</span>), the element's
content, (<span class="propinst-pause-after">'pause-after'</span>),
<span class="propinst-cue-after">'cue-after'</span>, and :after.
<li>Elements with a value of 'list-item'
for the <span class="propinst-display">'display'</span> property.
</ul>
<P>Below we describe the mechanisms associated with the <span
class="propinst-content">'content'</span> property.
<h2><a name="before-after-content">The</a> <span class="index-def"
title=":before|pseudo-elements:::before|before">:before</span> and <span
class="index-def" title=":after|pseudo-elements:::after|after">:after</span>
pseudo-elements</h2>
<p>Authors specify the style and location of generated content with
the :before and :after pseudo-elements. As their names indicate, the
:before and :after pseudo-elements specify the location of content
before and after an element's <a href="conform.html#doctree">document
tree</a> content. The <span class="propinst-content">'content'</span>
property, in conjunction with these pseudo-elements, specifies what is
inserted.
<div class=example>
<p>For example, the following rule inserts the string "Note: "
before the content of
every P element whose "class" attribute has the value "note":</p>
<pre>
P.note:before { content: "Note: " }
</pre>
</div>
<P>The formatting objects (e.g., boxes) generated by an element include
generated content. So, for example, changing the above style sheet
to:</p>
<pre class="example">
P.note:before { content: "Note: ";
border: solid green }
</pre>
<P>would cause a solid green border to be rendered around the entire
paragraph, including the initial string.
<P>The :before and :after pseudo-elements <a
href="cascade.html#inheritance">inherit</a> any inheritable properties
from the element in the document tree to which they are attached.</p>
<!-- Does the previous statement apply to all pseudo-elements? -IJ -->
<div class=example>
<p>For example, the following rules insert an open quote mark before every
Q element. The color of the quote mark will be red, but the font will
be the same as the font of the rest of the Q element:</p>
<pre>
Q:before {
content: open-quote;
color: red
}
</pre>
</div>
<p>In a :before or :after pseudo-element declaration, non-inherited
properties take their <a href="cascade.html#initial-value">initial
values</a>.</p>
<div class=example>
<p>So, for example, because the initial value of the <span
class="propinst-display">'display'</span> property is 'inline', the
quote in the previous example is inserted as an inline box (i.e.,
on the same line as the element's initial text content).
The next example explicitly sets the
<span class="propinst-display">'display'</span> property to
'block', so that the inserted text becomes a block:</p>
<pre>
BODY:after {
content: "The End";
display: block;
margin-top: 2em;
text-align: center;
}
</pre>
<P>Note that an audio user agent would speak the words "The End" after
rendering the rest of the BODY content.
</div>
<!-- Proposed -IJ -->
<P>User agents must ignore the following properties with :before and
:after pseudo-elements: <span
class="propinst-position">'position'</span>, <span
class="propinst-float">'float'</span>, <a href="#lists">list</a>
properties, and <a href="tables.html">table</a> properties.
<P>The :before and :after pseudo-elements elements allow
values of the <span class="propinst-display">'display'</span>
property as follows:
<ul>
<li>If the <a href="selector.html#subject">subject</a> of the
selector is a <a href="visuren.html#block-level">block-level</a>
element, allowed values are 'none', 'inline', 'block', and 'marker'.
If the value of the <span class="propinst-display">'display'</span>
has any other value, the pseudo-element will behave as if the value
were 'block'.
<li>If the <a href="selector.html#subject">subject</a> of the
selector is an <a href="visuren.html#inline-level">inline-level</a>
element, allowed values are 'none' and 'inline'.
If the value of the <span class="propinst-display">'display'</span>
has any other value, the pseudo-element will behave as if the value
were 'inline'.
</ul>
<div class="note"><P>
<em><strong>Note.</strong> Other values may be permitted in
future levels of CSS.</em>
</div>
<h2><a name="content">The</a> <span
class="propinst-content">'content'</span> property</h2>
<!-- #include src=properties/content.srb -->
<p>This property is used with the :before and :after pseudo-elements
to generate content in a document. Values have the following
meanings:</p>
<dl>
<dt><span class="index-inst" title="<string>"><span
class="value-inst-string"><strong><string></strong></span></span>
<dd>Text content
(see the section on <a href="syndata.html#strings">strings</a>).
<dt><span class="index-inst" title="<uri>"><span
class="value-inst-uri"><strong><uri></strong></span></span>
<dd>The value is a URI that designates an external resource.
If a user agent cannot support the resource because of the
<a href="media.html">media types</a> it supports, it must ignore the resource.
<strong>Note.</strong> CSS2 offers no
mechanism to change the size of the embedded object, or to provide a
textual description, like the "alt" or "longdesc" attributes do for
images in HTML. This may change in future levels of CSS.
<dt><span class="index-inst" title="<counter>"><span
class="value-inst-counter"><strong><counter></strong></span></span>
<dd><a href="syndata.html#counter">Counters</a> may be specified
with two different functions: 'counter()' or 'counters()'.
The former has two forms:
'counter(<var>name</var>)' or 'counter(<var>name</var>,
<var>style</var>)'.
The generated text is the value of the named
counter at this point in the formatting structure; it
is formatted in the indicated
<a href="#counter-styles">style</a> ('decimal' by default).
The latter function also has two forms:
'counter(<var>name</var>, <var>string</var>)' or 'counter(<var>name</var>,
<var>string</var>, <var>style</var>)'. The generated text is the value of all
counters with the given name at this point in the formatting structure,
separated by the specified string. The counters are rendered
in the indicated <a href="#counter-styles">style</a> ('decimal' by default).
See the section on <a href="#counters">automatic counters and
numbering</a> for more information.
<dt><span class="index-inst" title="open-quote"><span
class="value-inst-open-quote"><strong>open-quote</strong></span></span> and
<span class="index-inst" title="close-quote"><span
class="value-inst-close-quote"><strong>close-quote</strong></span></span>
<dd>These values are replaced by the appropriate string
from the <span class="propinst-quotes"><strong>'quotes'</strong></span> property.
<dt><span class="index-inst" title="no-open-quote"><span
class="value-inst-no-open-quote"><strong>no-open-quote</strong></span></span>
and <span class="index-inst" title="no-close-quote"><span
class="value-inst-no-close-quote"><strong>no-close-quote</strong></span></span>
<dd>Inserts nothing (the empty string), but increments (decrements)
the level of nesting for quotes.
<dt><span class="index-def" title="attr()"><strong>attr(X)</strong></span>
<dd>This function returns as a string the value of attribute X
for the subject of the selector. The
string is not parsed by the CSS processor. If the subject of the selector
doesn't have an attribute X, an empty string is returned. The
case-sensitivity of attribute names depends on the document language.
<strong>Note.</strong> In CSS2, it is not possible to refer to
attribute values for other elements of the selector.
</dl>
<P>The <span class="propinst-display">'display'</span> property
controls whether the content is placed in a block, inline, or marker
box.
<P>Authors should put <span class="propinst-content">'content'</span>
declarations in <span class="index-inst" title="@media"><a
href="media.html#at-media-rule">@media</a></span> rules when
the content is media-sensitive. For instance, literal
text may be used for any media group, but images only
apply to the visual + bitmap media groups, and sound files only
apply to the aural media group.
<div class="example">
<p>The following rule causes a sound file to be played
at the end of a quotation (see the section
on <a href="aural.html">aural style sheets</a> for additional
mechanisms):</p>
<pre>
@media aural {
BLOCKQUOTE:after { content: url(beautiful-music.wav) }
}
</pre>
</div>
<div class="example">
<p>The next rule inserts the text of the HTML "alt" attribute before the
image. If the image is not displayed, the reader will still see the
"alt" text.
<pre>
IMG:before { content: attr(alt) }
</pre>
</div>
<p>Authors may include newlines in the generated content by writing
the "\A" escape sequence in one of the strings after the <span
class="propinst-content">'content'</span> property. This inserts a
<span class="index-def" title="forced line break"><dfn> forced line
break</dfn></span>, similar to the BR element in HTML. See <a
href="syndata.html#strings">"Strings"</a> and <a
href="syndata.html#escaped-characters">"Characters and case"</a> for
more information on the "\A" escape sequence.
<div class="example"><P>
<PRE>
H1:before {
display: block;
text-align: center;
content: "chapter\A hoofdstuk\A chapitre"
}
</pre>
</div>
<P>Generated content does not alter the document tree. In particular, it
is not fed back to the document language processor (e.g., for
reparsing).
<div class=note>
<p><em><strong>Note.</strong> In future levels of CSS, the <span
class="propinst-content">'content'</span> property may accept
additional values, allowing it to vary the style of pieces
of the generated
content, but in CSS2, all the content of the :before or :after
pseudo-element has the same style.
</em></p>
</div>
<h2><a name="compact-run-in-gen">Interaction</a> of :before and :after
with <span class="index-inst" title="compact"><span
class="value-inst-compact">'compact'</span></span> and <span
class="index-inst" title="run-in"><span
class="value-inst-run-in">'run-in'</span></span> elements</h2>
<p>The following cases can occur:</p>
<!-- I'd rather say 'display: inline' than type 'inline' -IJ -->
<ol>
<li><strong>A 'run-in' or 'compact' element has a :before
pseudo-element of type 'inline':</strong> the pseudo-element is taken
into account when the size of the element's box is computed (for 'compact')
and is rendered inside the same block box as the element.
<li><strong>A 'run-in' or 'compact' element has an :after
pseudo-element of type 'inline':</strong> The rules of the previous
point apply.
<li><strong>A 'run-in' or 'compact' element has a :before
pseudo-element of type 'block':</strong> the pseudo-element is
formatted as a block above the element, and does not take part in the
computation of the element's size (for 'compact').
<li><strong>A 'run-in' or 'compact' element has an :after
pseudo-element of type 'block':</strong> both the element and its
:after pseudo-element are formatted as block boxes. The element
is <em>not</em> formatted as an inline box in its own :after
pseudo-element.
<!-- [?? This could also be defined the other way round,
but this seems easier to understand.] -->
<li><strong>The element following a 'run-in' or 'compact' element has
a :before of type 'block':</strong> the decision how to format the
'run-in'/'compact' element is made with respect to the block box
resulting from the :before pseudo-element.
<li><strong>The element following a 'run-in' or 'compact' element has
an :before of type 'inline':</strong> the decision how to format the
'run-in'/'compact' element depends on the <span
class="propinst-display">'display'</span> value of the element to which
the :before is attached.
</ol>
<div class="example">
<p>Here is an example of a 'run-in' header with an :after
pseudo-element, followed by a paragraph with a :before pseudo-element. All
pseudo-elements are inline (the default) in this example. When the
style sheet:</p>
<pre>
H3 { display: run-in }
H3:after { content: ": " }
P:before { content: "... " }
</pre>
<p>is applied to this source document:</p>
<pre class="html-example">
<H3>Centaurs</H3>
<P>have hoofs
<P>have a tail
</pre>
<p>The visual formatting will resemble:</p>
<pre class="none">
Centaurs: ... have hoofs
... have a tail
</pre>
</div>
<h2><a name="quotes">Quotation marks</a></h2>
<P>In CSS2, authors may specify, in a style-sensitive and
context-dependent manner, how user agents should render quotation
marks. The <span class="propinst-quotes">'quotes'</span> property
specifies pairs of quotation marks for each level of embedded
quotation. The <span class="propinst-content">'content'</span>
property gives access to those quotation marks and causes them to be
inserted before and after a quotation.
<H3><a name="quotes-specify">Specifying quotes</a> with the <span
class="propinst-quotes">'quotes'</span> property</H3>
<!-- #include src=properties/quotes.srb -->
<P>This property specifies quotation marks for any number of embedded
quotations. Values have the following meanings:</p>
<dl>
<dt><strong>none</strong>
<dd>The 'open-quote' and 'close-quote' values of the
<span class="propinst-content">'content'</span> property
produce no quotations marks.
<dt>[<span class="index-inst" title="<string>"><span
class="value-inst-string"><strong><string></strong></span></span>
<span class="index-inst" title="<string>"><span
class="value-inst-string"><strong><string></strong></span></span>]+
<dd>Values for the 'open-quote' and 'close-quote' values of the
<span class="propinst-content">'content'</span> property are taken
from this list of pairs of quotation marks (opening and
closing). The first (leftmost) pair represents the outermost level of
quotation, the second pair the first level of embedding, etc. The user
agent must apply the appropriate pair of quotation marks according to
the level of embedding.
</dl>
<div class="example">
<P>For example, applying the following style sheet:</p>
<PRE class="example">
/* Specify pairs of quotes for two levels in two languages */
Q:lang(en) { quotes: '"' '"' "'" "'" }
Q:lang(no) { quotes: "«" "»" "<" ">" }
/* Insert quotes before and after Q element content */
Q:before { content: open-quote }
Q:after { content: close-quote }
</PRE>
<P>to the following HTML fragment:</p>
<PRE class="html-example">
<HTML lang="en">
<HEAD>
<TITLE>Quotes</TITLE>
</HEAD>
<BODY>
<P><Q>Quote me!</Q>
</BODY>
</HTML>
</PRE>
<P>would allow a user agent to produce:</p>
<PRE class="ascii-art">
"Quote me!"
</PRE>
<P>while this HTML fragment:</p>
<PRE class="html-example">
<HTML lang="no">
<HEAD>
<TITLE>Quotes</TITLE>
</HEAD>
<BODY>
<P><Q>Trøndere gråter når <Q>Vinsjan på kaia</Q> blir deklamert.</Q>
</BODY>
</HTML>
</PRE>
<P>would produce:</p>
<PRE class="ascii-art">
«Trøndere gråter når <Vinsjan på kaia> blir deklamert.»
</PRE>
</div>
<div class="note"><P>
<em><strong>Note.</strong>
While the quotation marks specified by <span
class="propinst-quotes">'quotes'</span> in the previous examples are
conveniently located on computer keyboards, high quality typesetting
would require different ISO 10646 characters. The following
informative table lists some of the ISO 10646 quotation
mark characters:</em></p>
<TABLE border>
<TR><TH>Approximate rendering<TH>ISO 10646 code (hex)<TH>Description
<TR><TD>"<TD>0022<TD>QUOTATION MARK [the ASCII double quotation mark]
<TR><TD>'<TD>0027<TD>APOSTROPHE [the ASCII single quotation mark]
<TR><TD><<TD>2039<TD>SINGLE LEFT-POINTING ANGLE QUOTATION MARK
<TR><TD>><TD>203A<TD>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
<TR><TD>«<TD>00AB<TD>LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
<TR><TD>»<TD>00BB<TD>RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
<TR><TD>`<TD>2018<TD>LEFT SINGLE QUOTATION MARK [single high-6]
<TR><TD>'<TD>2019<TD>RIGHT SINGLE QUOTATION MARK [single high-9]
<TR><TD>``<TD>201C<TD>LEFT DOUBLE QUOTATION MARK [double high-6]
<TR><TD>''<TD>201D<TD>RIGHT DOUBLE QUOTATION MARK [double high-9]
<TR><TD>,,<TD>201E<TD>DOUBLE LOW-9 QUOTATION MARK [double low-9]
</TABLE>
</div>
<H3><a name="quotes-insert">Inserting quotes</a> with the <span
class="propinst-content">'content'</span> property</H3>
<p>Quotation marks are inserted in appropriate places in a document
with the <span class="index-def" title="open-quote"><a
class="value-def" name="value-def-open-quote">'open-quote'</a></span>
and <span class="index-def" title="close-quote"><a class="value-def"
name="value-def-close-quote">'close-quote'</a></span> values of the
<span class="propinst-content">'content'</span> property. Each
occurrence of 'open-quote' or 'close-quote' is replaced by one of the
strings from the value of <span
class="propinst-quotes">'quotes'</span>, based on the depth of
nesting.
<p>'Open-quote' refers to the first of a pair of quotes, 'close-quote'
refers to the second. Which pair of quotes is used depends on the
nesting level of quotes: the number of occurrences of 'open-quote' in
all generated text before the current occurrence, minus the number of
occurrences of 'close-quote'. If the depth is 0, the first pair is
used, if the depth is 1, the second pair is used, etc. If the depth is
greater than the number of pairs, the last pair is repeated.
<p>Note that this quoting depth is independent of the nesting
of the source document or the formatting structure.
<p>Some typographic styles require open quotation marks to be repeated
before every paragraph of a quote spanning several paragraphs, but
only the last paragraph ends with a closing quotation mark. In CSS,
this can be achieved by inserting "phantom" closing quotes. The
keyword <span class="index-def" title="no-close-quote"><a
class="value-def"
name="value-def-no-close-quote">'no-close-quote'</a></span> decrements
the quoting level, but does not insert a quotation mark.
<div class="example">
<p>The following style sheet puts opening quotation marks on every
paragraph in a BLOCKQUOTE, and inserts a single closing quote at the
end:
<pre>
BLOCKQUOTE P:before { content: open-quote }
BLOCKQUOTE P:after { content: no-close-quote }
BLOCKQUOTE P.last:after { content: close-quote }
</pre>
<P>This relies on the last paragraph being marked with a class "last",
since there are no selectors that can match the last child of an
element.
</div>
<p>For symmetry, there is also a <span class="index-def"
title="no-open-quote"><a class="value-def"
name="value-def-no-open-quote">'no-open-quote'</a></span> keyword,
which inserts nothing, but increments the quotation depth by one.
<div class="note"><p>
<em><strong>Note.</strong> If a quotation is in a different language than the
surrounding text, it is customary to quote the text with the quote
marks of the language of the surrounding text, not the language of the
quotation itself.
</em>
</div>
<div class="example">
<P>For example, French inside English:
<blockquote>
The device of the order of the garter is “Honi soit qui mal y
pense.”
</blockquote>
English inside French:
<blockquote>
Il disait: « Il faut mettre l'action en ‹ fast
forward ›.»
</blockquote>
<p>A style sheet like the following will set the 'quotes' property so
that 'open-quote' and 'close-quote' will work correctly on all elements.
These rules are for documents that contain only English, French, or
both. One rule is needed for every additional language.
Note the use of the child <span
class="index-inst" title="combinator"><a
name="selector.html#combinator">combinator</a></span> (">") to set
quotes on elements based on the language of the surrounding
text:</P>
<pre>
[LANG|=fr] > * { quotes: "«" "»" "\2039" "\203A" }
[LANG|=en] > * { quotes: "\201C" "\201D" "\2018" "\2019" }
</pre>
<p>The quotation marks for English are shown here in a form that most
people will be able to type. If you can type them directly, they will
look like this:
<pre>
[LANG|=fr] > * { quotes: "«" "»" "‹" "›" }
[LANG|=en] > * { quotes: "“" "”" "‘" "’" }
</pre>
</div>
<h2>Automatic <span class="index-def" title="counters"><a
name="counters">counters</a></span> and numbering</h2>
<p>Automatic numbering in CSS2 is controlled with two properties,
<span class="propinst-counter-increment">'counter-increment'</span>
and <span class="propinst-counter-reset">'counter-reset'</span>. The
counters defined by these properties are used with the counter() and
counters() functions of the the <span
class="propinst-content">'content'</span> property.
<!-- #include src=properties/counter-reset.srb -->
<!-- #include src=properties/counter-increment.srb -->
<p>The <span
class="propinst-counter-increment">'counter-increment'</span> property
accepts one or more names of counters (identifiers), each one
optionally followed by an integer. The integer indicates by how much the
counter is incremented for every occurrence of the element. The
default increment is 1. Zero and negative integers are allowed.
<p>The <span class="propinst-counter-reset">'counter-reset'</span>
property also contains a list of one or more names of counters, each
one optionally followed by an integer. The integer gives the value that
the counter is set to on each occurrence of the element. The default
is 0.
<p>If <span
class="propinst-counter-increment">'counter-increment'</span> refers
to a counter that is not in the <a href="#scope">scope (see below</a>) of any
<span class="propinst-counter-reset">'counter-reset'</span>, the
counter is assumed to have been reset to 0 by the root element.
<div class="example">
<p>This example shows a way to number chapters and sections with
"Chapter 1", "1.1", "1.2", etc.
<pre>
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>
<p>If an element increments/resets a counter and also uses it (in the
<span class="propinst-content">'content'</span> property of its
:before or :after pseudo-element), the counter is used <em>after</em>
being incremented/reset.
<p>If an element both resets and increments a counter, the counter is
reset first and then incremented.
<P>The <span class="propinst-counter-reset">'counter-reset'</span>
property follows the cascading rules. Thus, due to cascading, the
following style sheet:</p>
<pre class="example">
H1 { counter-reset: section -1 }
H1 { counter-reset: imagenum 99 }
</pre>
<p>will only reset 'imagenum'. To reset both counters, they have to be
specified together:</p>
<pre class="example">
H1 { counter-reset: section -1 imagenum 99 }
</pre>
<h3><a name="scope">Nested counters and scope</a></h3>
<p>Counters are "self-nesting", in the sense that re-using a counter
in a child element automatically creates a new instance of the
counter. This is important for situations like lists in HTML, where
elements can be nested inside themselves to arbitrary depth. It would
be impossible to define uniquely named counters for each level.
<div class="example">
<p>Thus, the following suffices to number nested list items. The
result is very similar to that of setting 'display:list-item' and
'list-style: inside' on the LI element:
<pre>
OL { counter-reset: item }
LI { display: block }
LI:before { content: counter(item) ". "; counter-increment: item }
</pre>
</div>
<p>The self-nesting is based on the principle that every element that
has a <span class="propinst-counter-reset">'counter-reset'</span> for
a counter X, creates a fresh counter X, the <span class="index-def"
title="scope"><dfn>scope</dfn></span> of which is the element, its
preceding siblings, and all the descendants of the element and its
preceding siblings.
<p>In the example above, an OL will create a counter, and all children
of the OL will refer to that counter.
<div class="html-example"> <p>If we denote by item[n] the
n<sup>th</sup> instance of the "item"
counter, and by "(" and ")" the beginning and end of a
scope, then the following HTML fragment will use the indicated
counters. (We assume the style sheet as given in the example above).
<pre>
<OL> <!-- (set item[0] to 0 -->
<LI>item <!-- increment item[0] (= 1) -->
<LI>item <!-- increment item[0] (= 2) -->
<OL> <!-- (set item[1] to 0 -->
<LI>item <!-- increment item[1] (= 1) -->
<LI>item <!-- increment item[1] (= 2) -->
<LI>item <!-- increment item[1] (= 3) -->
<OL> <!-- (set item[2] to 0 -->
<LI>item <!-- increment item[2] (= 1) -->
</OL> <!-- ) -->
<OL> <!-- (set item[3] to 0 -->
<LI> <!-- increment item[3] (= 1) -->
</OL> <!-- ) -->
<LI>item <!-- increment item[1] (= 4) -->
</OL> <!-- ) -->
<LI>item <!-- increment item[0] (= 3) -->
<LI>item <!-- increment item[0] (= 4) -->
</OL> <!-- ) -->
<OL> <!-- (reset item[4] to 0 -->
<LI>item <!-- increment item[4] (= 1) -->
<LI>item <!-- increment item[4] (= 2) -->
</OL> <!-- ) -->
</pre>
</div>
<p>The 'counters()' function generates a string composed of
the values of all counters with the same name, separated by a given string.
<div class="example"><P>
<P>The following style sheet numbers nested list items
as "1", "1.1", "1.1.1", etc.
<PRE>
OL { counter-reset: item }
LI { display: block }
LI:before { content: counters(item, "."); counter-increment: item }
</PRE>
</div>
<h3><a name="counter-styles">Counter styles</a></h3>
<p>By default, counters are formatted with decimal numbers, but all the
styles available for the <span
class="propinst-list-style-type">'list-style-type'</span> property are
also available for counters. The notation is:</P>
<pre>
counter(<var>name</var>)
</pre>
<p>for the default style, or:</p>
<pre>
counter(<var>name</var>, <span class="propinst-list-style-type">'list-style-type'</span>)
</pre>
<p>All the styles are allowed, including 'disc', 'circle', 'square',
and 'none'.
<div class="example"><P>
<pre>
H1:before { content: counter(chno, upper-latin) ". " }
H2:before { content: counter(section, upper-roman) " - " }
BLOCKQUOTE:after { content: " [" counter(bq, hebrew) "]" }
DIV.note:before { content: counter(notecntr, disc) " " }
P:before { content: counter(p, none) }
</pre>
</div>
<h3>Counters in elements with 'display: none'</h3>
<p>An element that is not displayed (<span
class="propinst-display">'display'</span> set to 'none') cannot
increment or reset a counter.
<div class="example">
<p>For example, with the following style sheet,
H2s with class "secret" do not increment 'count2'.
<pre>
H2.secret {counter-increment: count2; display: none}
</pre>
</div>
<p>Elements with <span class="propinst-visibility">'visibility'</span>
set to 'hidden', on the other hand, <em>do</em> increment counters.
<h2>Markers and lists</h2>
<P>Most block-level elements in CSS generate one principal block
box. In this section, we discuss two CSS mechanisms that cause an
element to generate two boxes: one <a
href="visuren.html#principal-box">principal</a> block box (for the
element's content) and one separate marker box (for decoration such as
a bullet, image, or number). The marker box may be positioned inside
or outside the principal box. Unlike :before and :after content, the
marker box does not affect the position of the principal box, whatever
the positioning scheme.
<P>The more general of the two mechanisms is new in CSS2 and is called
<span class="index-def" title="markers"><dfn>markers</dfn></span>.
The more limited mechanism involves the <a href="#lists">list</a>
properties of CSS1. The list properties give authors quick results for
many common ordered and unordered list scenarios. However, markers
give authors precise control over marker content and position. Markers
may be used with <a href="#counters">counters</a> to create new list
styles, to number margin notes, and much more.
<div class="html-example">
<P>For instance, the following example illustrates how markers may be
used to add periods after each numbered list item. This HTML program
and style sheet:</p>
<pre>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<TITLE>Creating a list with markers</TITLE>
<STYLE type="text/css">
LI:before {
display: marker;
content: counter(mycounter, lower-roman) ".";
counter-increment: mycounter;
}
</STYLE>
</HEAD>
<BODY>
<OL>
<LI> This is the first item.
<LI> This is the second item.
<LI> This is the third item.
</OL>
</BODY>
</HTML>
</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 <a href="./selector.html#descendant-selectors">descendant
selectors</a> and <a href="./selector.html#child-selectors">child
selectors</a>, it's possible to specify different marker types
depending on the depth of embedded lists.
<h3><a name="markers">Markers:</a> the <span
class="propinst-marker-offset">'marker-offset'</span> property</h3>
<P>Markers are created by setting the <span
class="propinst-display">'display'</span> property to 'marker' inside
a :before or :after pseudo-element. While 'block' and 'inline' :before
and :after content is part of the <a
href="visuren.html#principal-box">principal box</a> generated by the
element, 'marker' content is formatted in an independent marker box,
outside the principal box. Marker boxes are formatted as a single
line (i.e., one <a href="visuren.html#line-box">line box</a>), so they
are not as flexible as <a href="visuren.html">floats</a>. The marker
box is only created if the <span
class="propinst-content">'content'</span> property for the
pseudo-element actually generates content.
<P>Marker boxes have padding and borders, but no margins.
<P>For the :before pseudo-element, the baseline of text in the marker
box will be vertically aligned with the baseline of text in the first
line of content in the principal box. If the principal box contains no
text, the top outer edge of the marker box will be aligned with the
top outer edge of the principal box. For the :after pseudo-element,
the baseline of text in the marker box will be vertically aligned with
the baseline of text in the last line of content in the principal box.
If the principal box contains no text, the bottom outer edge of the
marker box will be aligned with the bottom outer edge of the
principal box.
<p>The height of a marker box is given by the <span
class="propinst-line-height">'line-height'</span> property. The
:before (:after) marker box participates in the height calculation of
the principal box's first (last) line box. Thus, markers are aligned
with the first and last line of an element's content, even though the
marker boxes live in distinct line boxes. If no first or last line
box exists in a principal box, the marker box establishes its line box
alone.
<P>The vertical alignment of a marker box within its line box is
specified with the <span
class="propinst-vertical-align">'vertical-align'</span> property.
<P>If the value of the <span class="propinst-width">'width'</span>
property is 'auto', the marker box <a
href="box.html#content-width">content width</a> is that of the
content, otherwise it is the value of <span
class="propinst-width">'width'</span>. For values of <span
class="propinst-width">'width'</span> less than the content
width, the <span class="propinst-overflow">'overflow'</span> property
specifies overflow behavior. Marker boxes may overlap principal
boxes. For values of <span class="propinst-width">'width'</span>
greater than the content width, the <span
class="propinst-text-align">'text-align'</span> property determines
the horizontal alignment of the content in the marker box.
<P>The <span class="propinst-marker-offset">'marker-offset'</span>
property specifies the horizontal offset between a marker box and the
associated <a href="visuren.html#principal-box">principal box</a>. The
distance is measured between their nearest <a
href="box.html#border-edge">border edges</a>. <strong>Note.</strong>
If a marker flows to the right of a float in a left-to-right
formatting context, the principal box will flow down the float's
right side, but the marker boxes will appear to the left of the float.
Since the principal box left border edge lies to the left
of the float (see the description of <a
href="visuren.html#floats">floats</a>), and marker boxes lie outside
the border edge of the principal box, the marker will also lie
to the left of the float. Analogous behavior applies for right-to-left
formatting when a marker flows to the left of a float.
<P>When the <span class="propinst-display">'display'</span> property
has the value 'marker' for content generated by an element with
'display: list-item', a marker box generated for ':before' replaces
the normal list item marker.
<div class="html-example">
<P>In the following example, the content is centered within a marker
box of a fixed width. This document:</p>
<PRE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<TITLE>Content alignment in the marker box</TITLE>
<STYLE type="text/css">
LI:before {
display: marker;
content: "(" numeric(counter) ")";
width: 6em;
text-align: center;
}
</STYLE>
</HEAD>
<BODY>
<OL>
<LI> This is the first item.
<LI> This is the second item.
<LI> This is the third item.
</OL>
</BODY>
</HTML>
</pre>
<p>should produce 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>
<P>The next example creates markers before and after
list items.
<div class="html-example">
<P>This document:</p>
<PRE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<TITLE>Markers before and after list items</TITLE>
<STYLE type="text/css">
@media screen, print {
LI:before {
display: marker;
content: url(smiley.gif);
LI:after {
display: marker;
content: url(sad.gif);
}
}
</STYLE>
</HEAD>
<BODY>
<UL>
<LI>first list item comes first
<LI>second list item comes second
</UL>
</BODY>