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
3606 lines (2765 loc) · 131 KB
/
Overview.html
File metadata and controls
3606 lines (2765 loc) · 131 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.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!--*- Mode: Text; fill-column: 95 -*-->
<html lang=en>
<head><meta content="text/html" http-equiv=Content-Type>
<title>CSS3 Generated and Replaced Content Module</title>
<link href="../default.css" rel=stylesheet type="text/css">
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel=stylesheet
type="text/css">
<style type="text/css">
.green { color: green; }
.navy { color: navy; }
.purple { color: purple; }
</style>
</head>
<!-- TODO:
!
! * place 'property' into marked up property elements
! * similarly with '::pseudo' and examples
! * http://lists.w3.org/Archives/Member/w3c-css-wg/2003JanMar/0170.html
! * string-set and co
! * need to increment the footnote, endnote and section-note counters
! * cross references, as in http://www.w3.org/Style/Group/2001/MO-css3-page-20010205
! * date() and time()
! * drop nesting
!
!-->
<body>
<div class=head>
<p><a class=logo href="http://www.w3.org/" rel=home><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a><a class=logo
href="../../" rel=in-activity><img alt="CSS WG"
src="../../../Woolly/woolly-icon.png"></a></p>
<h1>CSS3 Generated and Replaced Content Module</h1>
<h2 class="no-num no-toc" id=longstatus-date-10-july-2005>Editor's Draft
14 April 2009</h2>
<dl>
<dt>This version:
<dd><a
href="http://dev.w3.org/csswg/css3-content/">http://dev.w3.org/csswg/css3-content/</a></dd>
<!-- <dd><a
href="http://www.w3.org/TR/2009/WD-css3-content-20090414">http://www.w3.org/TR/2009/WD-css3-content-20090414</a></dd> -->
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-content">http://www.w3.org/TR/css3-content</a>
<dt>Previous versions:
<dd><a
href="http://www.w3.org/TR/2003/WD-css3-content-20030514/">http://www.w3.org/TR/2003/WD-css3-content-20030514/</a>
<dd><a
href="http://www.w3.org/TR/1998/REC-CSS2-19980512/generate.html">http://www.w3.org/TR/1998/REC-CSS2-19980512/generate.html</a>
<dt>Editors:
<dd>Ian Hickson, <a href="mailto:ian@hixie.ch">ian@hixie.ch</a>
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2009 <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.org/"><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>This CSS3 Module describes how to insert and move content around a
document, in order to create footnotes, endnotes, section notes. Inserted
content can also introduce counters and strings, which can be used for
running headers and footers, section numbering, and lists. Finally,
techniques for declaring replaced images, as well as scaling and cropping
them using CSS, are described.
<h2 class=no-num id=status>Status of this document</h2>
<p>This is <em>not yet</em> a working draft of a CSS level 3 module. It
aspires to eventually become a CSS3 Recommendation.
<p>This document is written in the context of the CSS working group which
is part of the <a href="http://www.w3.org/Style/">style activity</a> (see
<a href="http://www.w3.org/Style/Activity">summary</a>).
<p>Comments on, and discussions of this draft can be sent on the (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
mailing list <a href="mailto:www-style@w3.org">www-style@w3.org</a> (see
<a href="http://www.w3.org/Mail/Request">instructions</a>). W3C Members
can also send comments directly to the CSS working group.
<p>This is a working draft and may therefore be updated, replaced or
rendered obsolete by other W3C documents at any time. It is inappropriate
to use W3C Working Drafts as reference material or to cite them as other
than "work in progress". Its publication does not imply endorsement by the
W3C membership or the <a href="http://www.w3.org/Style/Group">CSS Working
Group</a> (<a href="http://cgi.w3.org/MemberAccess/AccessRequest">members
only</a>).
<p>Patent disclosures relevant to CSS may be found on the Working Group's
public <a href="http://www.w3.org/Style/CSS/Disclosures">patent disclosure
page.</a>
<p>To find the latest version of this working draft, please follow the
"Latest version" link above, or visit the list of W3C <a
href="http://www.w3.org/TR/">Technical Reports</a>.
<p>This document may be available in translations in the future. The
English version of this specification is the only normative version.
<h3 class=no-num id=crec>Candidate Recommendation Exit Criteria</h3>
<p>For this specification to exit the CR stage, the following conditions
must be met:
<ol>
<li>
<p>There must be at least two interoperable implementations for every
feature. For the purposes of this criterion, we define the following
terms:</p>
<dl>
<dt>feature
<dd>
<p> A section or subsection of the specification.</p>
<dt>interoperable
<dd>
<p>passing the respective test cases in the test suite, or, if the
implementation is not a web browser, equivalent tests. Every relevant
test in the test suite should have an equivalent test created if such
a UA is to be used to claim interoperability. In addition if such a UA
is to be used to claim interoperability, then there must one or more
additional UAs which can also pass those equivalent tests in the same
way for the purpose of interoperability. The equivalent tests must be
made publicly available for the purposes of peer review.</p>
<dt>implementation
<dd>
<p>a user agent which:</p>
<ol class=inline>
<li>implements the feature.
<li>is available (i.e. publicly downloadable or available through some
other public point of sale mechanism). This is the "show me"
requirement.
<li>is shipping (i.e. development, private or unofficial versions are
insufficient).
<li>is not experimental (i.e. is intended for a wide audience and
could be used on a daily basis).
</ol>
</dl>
<li>
<p>For every feature, error handling must be well defined, and
non-supporting UAs with a significant market share (if any) must
interoperate on correct error handling, even if supporting UAs
interoperate on the correct support as per the previous criterion. For
the purposes of this criterion, we further define the following terms:</p>
<dl>
<dt>error handling
<dd>...
<dt>non-supporting UAs with a significant market share
<dd>...
<dt>interoperate
<dd>...
</dl>
<li>
<p>A minimum of six months of the CR period must have elapsed. This is to
ensure that enough time is given for any remaining major errors to be
caught.
<li>
<p>The CR period will be extended if implementations are slow to appear.
<li>
<p>Features will be dropped (thus reducing the list of "all" features
mentioned above) if two or more interoperable implementations of those
features are not found by the end of the CR period.
<li>
<p>Features will also be dropped if sufficient and adequate tests (by
judgment of the working group) have not been produced for those features
by the end of the CR period.
<li>
<p>If implementation feedback warrants it, or if implementations are not
found to be sufficiently interoperable, this specification will be
returned to Working Draft stage to address the issues raised and reasons
for implementation differences.
</ol>
<h2 class="no-num no-toc" id=contents>Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li class=no-num><a href="#status">Status of this document</a>
<ul class=toc>
<li class=no-num><a href="#crec">Candidate Recommendation Exit
Criteria</a>
</ul>
<li><a href="#dependencies"><span class=secno>1 </span>Dependencies on
other modules</a>
<li><a href="#introduction"><span class=secno>2 </span>Introduction</a>
<ul class=toc>
<li><a href="#conformance-requirements"><span class=secno>2.1
</span>Conformance Requirements</a>
</ul>
<li><a href="#terminology"><span class=secno>3 </span>Terminology</a>
<li><a href="#pseudo-elements"><span class=secno>4
</span>Pseudo-elements</a>
<ul class=toc>
<li><a href="#syntax"><span class=secno>4.1 </span>Syntax</a>
<li><a href="#inserting-content-into-an-element-the-be"><span
class=secno>4.2 </span>Inserting content into an element: the
‘<code class=css>::before</code>’ and ‘<code
class=css>::after</code>’ pseudo-elements</a>
<ul class=toc>
<li><a href="#nesting-before-and-after-pseudo-elements"><span
class=secno>4.2.1 </span>Nesting ‘<code
class=css>::before</code>’ and ‘<code
class=css>::after</code>’ pseudo-elements</a>
<li><a href="#inserting-multiple-before-and-after-pseu"><span
class=secno>4.2.2 </span>Inserting multiple ‘<code
class=css>::before</code>’ and ‘<code
class=css>::after</code>’ pseudo-elements</a>
</ul>
<li><a href="#wrapping-elements-in-pseudo-elements-wit"><span
class=secno>4.3 </span>Wrapping elements in pseudo-elements with
‘<code class=css>::outside</code>’</a>
<ul class=toc>
<li><a href="#mixing-outside-with-before-and-after"><span
class=secno>4.3.1 </span>Mixing ‘<code
class=css>::outside</code>’ with ‘<code
class=css>::before</code>’ and ‘<code
class=css>::after</code>’</a>
</ul>
<li><a href="#inserting-new-content-later-in-the-docum"><span
class=secno>4.4 </span>Inserting new content later in the document tree
with ‘<code class=css>::alternate</code>’</a>
<ul class=toc>
<li><a href="#mixing-alternate-with-outside-before-and"><span
class=secno>4.4.1 </span>Mixing ‘<code
class=css>::alternate</code>’ with ‘<code
class=css>::outside</code>’, ‘<code
class=css>::before</code>’, and ‘<code
class=css>::after</code>’</a>
</ul>
<li><a href="#block-markers-the-marker-pseudo-element"><span
class=secno>4.5 </span>Block markers: The ‘<code
class=css>::marker</code>’ pseudo-element</a>
<li><a href="#line-markers-the-line-marker-pseudo-elem"><span
class=secno>4.6 </span>Line markers: The ‘<code
class=css>::line-marker</code>’ pseudo-element</a>
</ul>
<li><a href="#moving-content-to-later-in-the-document-"><span
class=secno>5 </span>Moving content to later in the document: the
‘<code class=property>move-to</code>’ property</a>
<li><a href="#the-display-property"><span class=secno>6 </span>The
‘<code class=property>display</code>’ property</a>
<li><a href="#specifying-quotes-with-the-quotes-proper"><span
class=secno>7 </span>Specifying quotes with the <span
class=propinst-quotes>‘<code
class=property>quotes</code>’</span> property</a>
<ul class=toc>
<li><a href="#inserting-quotes-with-the-content-proper"><span
class=secno>7.1 </span>Inserting quotes with the ‘<code
class=property>content</code>’ property</a>
</ul>
<li><a href="#counters"><span class=secno>8 </span>Automatic counters and
numbering: the ‘<code
class=property>counter-increment</code>’ and ‘<code
class=property>counter-reset</code>’ properties</a>
<ul class=toc>
<li><a href="#nested-counters-and-scope"><span class=secno>8.1
</span>Nested counters and scope</a>
<li><a href="#counter-styles"><span class=secno>8.2 </span>Counter
styles</a>
<li><a href="#counters-in-elements-with-display-none"><span
class=secno>8.3 </span>Counters in elements with ‘<code
class=css>display: none</code>’</a>
<li><a href="#reserved-counter-names"><span class=secno>8.4
</span>Reserved Counter Names</a>
</ul>
<li><a href="#datetime"><span class=secno>9 </span>Dates and times: the
‘<code class=css>date()</code>’ and ‘<code
class=css>time()</code>’ functions and the ‘<code
class=property>date-style</code>’ property</a>
<li><a href="#strings"><span class=secno>10 </span>Named strings</a>
<li><a href="#counter-and-string"><span class=secno>11 </span>‘<code
class=css>@counter</code>’ and ‘<code
class=css>@string</code>’</a>
<ul class=toc>
<li><a href="#counter"><span class=secno>11.1 </span>‘<code
class=css>@counter</code>’</a>
<li><a href="#string"><span class=secno>11.2 </span>‘<code
class=css>@string</code>’</a>
<li><a href="#page-policy"><span class=secno>11.3 </span>Determining
which counter or string-set value to use: the ‘<code
class=property>page-policy</code>’ property</a>
</ul>
<li><a href="#inserting-and-replacing-content-with-the"><span
class=secno>12 </span>Inserting and replacing content with the <span
class=propinst-content>‘<code
class=property>content</code>’</span> property</a>
<li><a href="#replacedContent"><span class=secno>13 </span>Replaced
content</a>
<ul class=toc>
<li><a href="#the-crop-property"><span class=secno>13.1 </span>The
‘<code class=property>crop</code>’ property</a>
<li><a href="#intrinsic-dimensions"><span class=secno>13.2
</span>Intrinsic dimensions</a>
</ul>
<li><a href="#examples"><span class=secno>14 </span>Examples</a>
<ul class=toc>
<li><a href="#footnote-elements"><span class=secno>14.1 </span>Footnote
elements</a>
<li><a href="#footnote-attributes"><span class=secno>14.2
</span>Footnote attributes</a>
<li><a href="#styling-footnotes"><span class=secno>14.3 </span>Styling
footnotes</a>
<li><a href="#multiple-styles-on-one-element"><span class=secno>14.4
</span>Multiple styles on one element</a>
<li><a href="#section-notes"><span class=secno>14.5 </span>Section
notes</a>
<li><a href="#top-floats"><span class=secno>14.6 </span>Top floats</a>
<li><a href="#wrapping-terms-and-definitions"><span class=secno>14.7
</span>Wrapping terms and definitions</a>
</ul>
<li><a href="#test-suite"><span class=secno>15 </span>Test suite</a>
<li><a href="#profiles"><span class=secno>16 </span>Profiles</a>
<li class=no-num><a href="#acknowledgments">Acknowledgments</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="#index">Index</a>
<li class=no-num><a href="#property-index">Property index</a>
</ul>
<!--end-toc-->
<h2 id=dependencies><span class=secno>1 </span>Dependencies on other
modules</h2>
<p>This CSS3 module depends on the following other CSS3 modules:
<ul>
<li><cite>CSS3 module: syntax</cite> <a href="#CSS3SYN"
rel=biblioentry>[CSS3SYN]<!--{{!CSS3SYN}}--></a>
<li><cite>CSS3 module: values and units</cite> <a href="#CSS3VAL"
rel=biblioentry>[CSS3VAL]<!--{{!CSS3VAL}}--></a>
<li><cite>CSS3 module: selectors</cite> <a href="#SELECT"
rel=biblioentry>[SELECT]<!--{{!SELECT}}--></a>
<li><cite>CSS3 module: lists</cite> <a href="#CSS3LIST"
rel=biblioentry>[CSS3LIST]<!--{{!CSS3LIST}}--></a>
<li><cite>CSS3 module: block box model</cite> <a href="#CSS3BOX"
rel=biblioentry>[CSS3BOX]<!--{{!CSS3BOX}}--></a>
<li><cite>CSS3 module: inline box model</cite> <a href="#CSS3LINE"
rel=biblioentry>[CSS3LINE]<!--{{!CSS3LINE}}--></a>
<li><cite>CSS3 module: paged media</cite> <a href="#CSS3PAGE"
rel=biblioentry>[CSS3PAGE]<!--{{!CSS3PAGE}}--></a>
</ul>
<!--=======================================================================-->
<h2 id=introduction><span class=secno>2 </span>Introduction</h2>
<p>In some cases, authors may want user agents to render content that does
not come from the document tree. One familiar example of this is a
numbered list; the author does not want to mark the numbers up explicitly,
he or she wants the user agent to generate them automatically. Counters
and markers are used to achieve these effects.
<pre>
ol { counter-reset: item; }
li { display: list-item; counter-increment: item; }
li::marker { content: counter(item, decimal) '.'; }
</pre>
<p>A simpler way to write this is:
<pre>
li { display: list-item; list-style: decimal; }
</pre>
<p>Similarly, authors may want the user agent to insert the word "Figure"
before the caption of a figure, or "Chapter 7" on a line before the
seventh chapter title.
<pre>
figure > caption::before { content: "Figure: "; }
chapter:nth-child(7) > title::before { content: "Chapter 7\A"; }
</pre>
<p>The last example could also be written in a more generic way using
counters:
<pre>
chapter { counter-increment: chapter; }
chapter > title::before { content: "Chapter " counter(chapter) "\A"; }
</pre>
<p>Another common effect is replacing elements with images or other
multimedia content. Since not all user agents support all multimedia
formats, fallbacks may have to be provided.
<pre>
/* Replace <logo> elements with the site's logo, using a format
* supported by the UA */
logo { content: url(logo.mov), url(logo.mng), url(logo.png), none; }
/* Replace <figure> elements with the referenced document, or,
* failing that, with either the contents of the alt attribute or the
* contents of the element itself if there is no alt attribute */
figure[alt] { content: attr(href, url), attr(alt); }
figure:not([alt]) { content: attr(href, url), contents; }
</pre>
<p>Authors may also wish to move content to a later position in a document,
for instance placing images at the bottom (or top) of the page.
<pre>
img { move-to: page-top; } /* move images to page-top */
@page { padding-top: 10em; } /* leave a gap at the top of the page */
body:after { /* place a box at the top of each page */
position: fixed; top: 0; left: 0; right: 0; height: 10em;
content: pending(page-top); /* insert the images moved to page-top */
}
</pre>
<p>In some cases, content may be inserted, alternate content moved to a
later place in the flow, and a list marker inserted next to this alternate
content. For example, footnotes or endnotes.
<pre>
a[href]::after {
counter-increment: footnote-number;
content: counter(footnote-number, footnotes);
}
a[href]::after::alternate {
display: list-item;
content: attr(href);
move-to: footnotes;
}
a[href]::after::alternate::marker {
content: counter(footnote-number, footnotes);
}
@page {
counter-reset: footnote-number;
@footnote {
content: pending(footnotes);
}
}
</pre>
<p>Using initial values, the last example can also be written as:
<pre>
a[href]::after { content: footnote; }
a[href]::after::alternate { content: attr(href); }
</pre>
<p>For simpler cases, e.g. where an element is simply to be used as an
endnote directly, only a single declaration is required.
<pre>
p.note { content: endnote; }
</pre>
<p>The initial values of the other properties are set up so that the result
is as expected.
<p>Another effect commonly requested by authors is that of line numbering.
This module introduces the ‘<code
class=css>::line-marker</code>’ pseudo-element that is attached to
the front of every line box, which can be used for this purpose.
<pre>
pre { counter-reset: line; }
pre::line-marker { counter-increment: line; content: counter(line) "."; }
</pre>
<p>This pseudo-element can also be used to simulate the indentation style
found in e-mail communication:
<pre>
blockquote { margin: 0; padding: 0 0 0 2em; } <!-- replace 'em' with 'ch' XXX -->
blockquote > blockquote { margin-left: -1em; }
blockquote::line-marker { width: 2em; text-align: left; content: ">"; }
</pre>
<p>Generated content based on the <code>cite</code> and
<code>datetime</code> attributes can create introductions or citations on
the fly as well.
<h3 id=conformance-requirements><span class=secno>2.1 </span>Conformance
Requirements</h3>
<p>Finally, in this document, requirements are expressed using the key
words "MUST", "MUST NOT", "REQUIRED", "SHALL" and "SHALL NOT".
Recommendations are expressed using the key words "SHOULD", "SHOULD NOT"
and "RECOMMENDED". "MAY" and "OPTIONAL" are used to indicate optional
features or behavior. These keywords are used in accordance with <a
href="#RFC2119" rel=biblioentry>[RFC2119]<!--{{!RFC2119}}--></a>. For
legibility these keywords are used in lowercase form.</p>
<!--=======================================================================-->
<h2 id=terminology><span class=secno>3 </span>Terminology</h2>
<p>This module introduces several pseudo-elements and allows them to nest
in certain predefined ways. In order to explain the relationships between
these nested pseudo-elements, three new terms have been coined.
<dl>
<dt><dfn id=superior-parent>superior parent</dfn>
<dd> A pseudo-element's superior parent is the element or pseudo-element
to which it is associated. e.g. the superior parent of the pseudo-element
matched by ‘<code class=css>::before::after</code>’ is the
pseudo-element matched by ‘<code class=css>::before</code>’,
and <em>that</em> pseudo-element's superior parent is the element itself.
The suporior parent of an ‘<code
class=css>::outside(<var>n</var>)</code>’ pseudo-element is the
‘<code class=css>::outside(<var>n-1</var>)</code>’
pseudo-element. Note that an element never has a superior parent, and a
pseudo-element always has exactly one.
<dt><dfn id=superior-siblings>superior siblings</dfn>
<dd> The ‘<code class=css>::before</code>’ or ‘<code
class=css>::after</code>’ pseudo-elements that have lower numeric
arguments. e.g. ‘<code class=css>::before(2)</code>’ is a
superior sibling of ‘<code class=css>::before(5)</code>’.
Only ‘<code class=css>::before</code>’ and ‘<code
class=css>::after</code>’ pseudo-elements with numeric arguments
greater than 1 have superior siblings.
<dt><dfn id=superior>superior</dfn>
<dd> Any element or pseudo-element that is either a superior parent or
superior sibling.
</dl>
<p class=issue>These terms are horrible, but they were the only ones I
could think of that didn't confusingly clash with DOM terminology. Example
of the horridness of the terms: the superior parent of an ‘<code
class=css>::outside</code>’ pseudo-element is its rendering tree
child, whose rendering hree sibling ‘<code
class=css>::before</code>’ has the ‘<code
class=css>::outside</code>’ pseudo-element as its superior parent.
<p class=issue>We need a term which means "element or pseudo-element".</p>
<!--=======================================================================-->
<h2 id=pseudo-elements><span class=secno>4 </span>Pseudo-elements</h2>
<p>At the heart of generated content lies pseudo-elements. Pseudo-elements
create abstractions about the document tree beyond those specified by the
document language. For instance, document languages do not offer
mechanisms to access the first letter or first line of an element's
content. CSS pseudo-elements allow style sheet designers to refer to this
otherwise inaccessible information. Pseudo-elements also provide style
sheet designers a way to assign style to content that does not exist in
the source document.
<h3 id=syntax><span class=secno>4.1 </span>Syntax</h3>
<p>Certain combinations of multiple pseudo-elements per selector are
allowed. All pseudo-elements must appear in a single chain at the end of
the selector, with no intervening combinators.
<p>The pseudo-element part of the selector consists of an optional set of
"structural" pseudo-elements, optionally followed by a single formatting
pseudo-element.
<p>The structural pseudo-elements are alternating sets of an ‘<code
class=css>::outside</code>’ pseudo-element and one or more
‘<code class=css>::before</code>’, ‘<code
class=css>::after</code>’, or ‘<code
class=css>::alternate</code>’ pseudo-elements. (So basically any
number of ‘<code class=css>::outside</code>’, ‘<code
class=css>::before</code>’, ‘<code
class=css>::after</code>’, and ‘<code
class=css>::alternate</code>’ pseudo-elements, so long as no two
‘<code class=css>::outside</code>’ pseudo-elements are
adjacent, as that is meaningless.)
<p>The formatting pseudo-elements are ‘<code
class=css>::first-line</code>’, ‘<code
class=css>::first-letter</code>’, ‘<code
class=css>::marker</code>’, ‘<code
class=css>::line-marker</code>’, and ‘<code
class=css>::selection</code>’. Only one of these may occur, and if
present, it must be the last pseudo-element in the chain.
<p>The allowed order for pseudo-elements is formally described by the
following pseudo-BNF grammar:
<pre>
pseudo-elements := structural-pseudo-elements? formatting-pseudo-element?
structural-pseudo-elements :=
( '::outside'? [ '::before' | '::after' | '::alternate' ] )* '::outside'?
formatting-pseudo-element :=
'::first-line' | '::first-letter' | '::marker' | '::line-marker' | '::selection'
</pre>
<p>The ‘<code class=css>::outside</code>’, ‘<code
class=css>::before</code>’, and ‘<code
class=css>::after</code>’ pseudo-elements have two forms,
‘<code class=css>::outside</code>’, ‘<code
class=css>::before</code>’, and ‘<code
class=css>::after</code>’ and ‘<code
class=css>::outside(<var>n</var>)</code>’, ‘<code
class=css>::before(<var>n</var>)</code>’, and ‘<code
class=css>::after(<var>n</var>)</code>’, where <var>n</var> is an
integer. If the parameter part is omitted then ‘<code
class=css>1</code>’ is implied. For example, ‘<code
class=css>::before(1)</code>’ is the same as ‘<code
class=css>::before</code>’.
<p>For compatability with previous levels of CSS, the ‘<code
class=css>::before</code>’, ‘<code
class=css>::after</code>’, ‘<code
class=css>::first-line</code>’ and ‘<code
class=css>::first-letter</code>’ pseudo-elements do not require two
colons. This does not apply to any other pseudo-element. Authors are
encouraged to use the new two-colon forms.</p>
<!--=======================================================================-->
<h3 id=inserting-content-into-an-element-the-be><span class=secno>4.2
</span>Inserting content into an element: the ‘<code
class=css>::before</code>’ and ‘<code
class=css>::after</code>’ pseudo-elements</h3>
<p>The ‘<code class=css>::before</code>’ and ‘<code
class=css>::after</code>’ pseudo-elements are used to insert content
immediately before and immediately after the content of an element (or
other pseudo-element). The ‘<code class=property><a
href="#content">content</a></code>’ propety is used to specify the
content to insert.
<div class=example>
<p>For example, the following rule replaces the content of
<code><abbr></code> elements with the contents of the element's
<code>title</code> attribute:</p>
<pre>
abbr { content: attr(title); }
</pre>
<p>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:
<pre class=example>
P.note:before { content: "Note: " }
P.note { border: solid green }
</pre>
<p>...would cause a solid green border to be rendered around the entire
paragraph, including the initial string.
<p>Typically, the ‘<code class=css>::before</code>’ and
‘<code class=css>::after</code>’ pseudo-elements inherit any
inheritable properties from the element in the document tree to which they
are attached. In the general case, they inherit their properties from
their superior parent.
<p>For a ‘<code class=css>::before</code>’ or ‘<code
class=css>::after</code>’ pseudo-element to be generated, all of the
elements and pseudo-elements leading to it must be generated, and the
pseudo-element must not have its ‘<code class=property><a
href="#content">content</a></code>’ property set to ‘<code
class=property><a href="#inhibit">inhibit</a></code>’ or its
‘<code class=property><a href="#display">display</a></code>’
property set to ‘<code class=property><a
href="#none1">none</a></code>’. Note that for ‘<code
class=css>::before</code>’ and ‘<code
class=css>::after</code>’ pseudo-elements, the initial value of
‘<code class=property><a href="#content">content</a></code>’
computes to ‘<code class=property><a
href="#inhibit">inhibit</a></code>’.
<p>Using a ‘<code class=css>::before</code>’ pseudo-element in
the context of the anonymous table elements works exactly as if an actualy
element had been introduced. For example:
<pre>
.example::before { content: "D" }
</pre>
<pre>
<table>
<tr>
<td>A</td> <td>B</td> <td>C</td>
</tr>
<tr class="example">
<td>E</td> <td>F</td>
</tr>
</table>
</pre>
<p>An anonymous table cell box is generated around the ‘<code
class=css>::before</code>’ content in this case, resulting in a
3×2 table.
<h4 id=nesting-before-and-after-pseudo-elements><span class=secno>4.2.1
</span>Nesting ‘<code class=css>::before</code>’ and
‘<code class=css>::after</code>’ pseudo-elements</h4>
<p>The selector ‘<code class=css>::before::before</code>’
represents a pseudo-element contained at the start of a pseudo-element
contained at the start of an element.
<p>For example, the following rules:
<pre>
div { content: 'A' }
div::before { content: 'B'; }
div::before::before { content: 'C'; }
</pre>
<p>...would result in the following rendering objects:
<pre>
,-----------------------.
| ,---------. |
| | ,---. | |
| | | C | B | A |
| | `---' | |
| `---------' |
`-----------------------'
</pre>
<h4 id=inserting-multiple-before-and-after-pseu><span class=secno>4.2.2
</span>Inserting multiple ‘<code class=css>::before</code>’
and ‘<code class=css>::after</code>’ pseudo-elements</h4>
<p>In contrast with the previous section, the selector ‘<code
class=css>::before(2)</code>’ represents a pseudo-element before
another, both of which are contained at the start of an element.
<p>For example, the following rules:
<pre>
div { content: 'A' }
div::before { content: 'B'; }
div::before(2) { content: 'C'; }
</pre>
<p>...would result in the following rendering objects:
<pre>
,-----------------------.
| ,---. ,---. |
| | C | | B | A |
| `---' `---' |
`-----------------------'
</pre>
<p>The ‘<code class=css>::before</code>’ selector is exactly
equivalent to ‘<code class=css>::before(1)</code>’.
<p>A pseudo-element only exists if all the elements and pseudo-elements
leading up to it exist. For instance, in the following example, only one
pseudo-element is generated, the first one:
<pre>
div { content: 'A' }
div::before { content: 'B'; }
div::before(2) { content: inhibit; }
div::before(3) { content: 'C'; }
</pre>
<p>It would result in the following rendering objects:
<pre>
,-----------------------.
| ,---. |
| | B | A |
| `---' |
`-----------------------'
</pre>
<!--=======================================================================-->
<h3 id=wrapping-elements-in-pseudo-elements-wit><span class=secno>4.3
</span>Wrapping elements in pseudo-elements with ‘<code
class=css>::outside</code>’</h3>
<p>An ‘<code class=css>::outside</code>’ pseudo-element is one
that is generated immediately outside the pseudo-element's <a
href="#superior">superior</a>.
<p>When given a parameter, ‘<code
class=css>::outside(<var>n</var>)</code>’ represents an
<var>n</var>th pseudo-element generated immediately around the
<var>n-1</var>th pseudo-element.
<p>For example, the following rules:
<pre>
div { display: block; border: dashed; }
div::outside { display: block; border: dashed; }
div::outside(2) { display: block; border: dashed; }
</pre>
<p>...would result in the following rendering objects:
<pre>
,-----------------------. <-- border of ::outside(2)
| ,-------------------. | <-- border of ::outside
| | ,---------------. | | <-- border of DIV
| | | DIV | | |
| | `---------------' | |
| `-------------------' |
`-----------------------'
</pre>
<p>A similar result would be achieved by using three nested DIV elements
(except of course that would require changing the document source, which
is not always possible).
<p>One difference between using elements and using pseudo-elements is that
the pseudo-elements inherit from the elements (or pseudo-elements) that
generate them, not from those they are contained within.
<p>For example, if we assume the following rules:
<pre>
div { display: block; border: green solid; }
div::outside(1) { display: block; border: inherit; }
div::outside(2) { display: block; border: red solid; }
</pre>
<p>...then the outermost border (from the ‘<code
class=css>::outside(2)</code>’) will be red, but the middle border
(from ‘<code class=css>::outside(1)</code>’) will be the same
colour as the inner most border (from the element itself), namely green.
<p>For an ‘<code class=css>::outside</code>’ pseudo-element to
be generated, all of the elements and pseudo-elements leading to it must
be generated, and the pseudo-element itself must not have its ‘<code
class=property><a href="#display">display</a></code>’ property set
to ‘<code class=property><a href="#none1">none</a></code>’.
Note that the initial value of ‘<code class=property><a
href="#display">display</a></code>’ computes to ‘<code
class=property><a href="#none1">none</a></code>’ on ‘<code
class=css>::outside</code>’ pseudo-elements.
<p>It is possible to float an element and then give it an ‘<code
class=css>::outside</code>’ pseudo-element, in which case the
pseudo-element is in-flow, not floated.
<p>For example:
<pre>
p { float: right; color: green; }
p::outside { display: inline; border: solid; }
</pre>
<p>...results in an empty inline element with a solid green border being
placed in the flow at the point where the float is taken out of flow.
<p>When an element is moved with the ‘<code class=property><a
href="#move-to">move-to</a></code>’ property, however, ‘<code
class=css>::outside</code>’ pseudo-elements are moved too.
<p>The ‘<code class=property><a
href="#content">content</a></code>’ property does not apply to
‘<code class=css>::outside</code>’ pseudo-elements.
<h4 id=mixing-outside-with-before-and-after><span class=secno>4.3.1
</span>Mixing ‘<code class=css>::outside</code>’ with
‘<code class=css>::before</code>’ and ‘<code
class=css>::after</code>’</h4>
<p>An ‘<code class=css>::outside</code>’ pseudo-element can
have any number of ‘<code class=css>::before</code>’ or
‘<code class=css>::after</code>’ pseudo-elements of its own.
They are inserted before and after the ‘<code
class=css>::outside</code>’ pseudo-element's contents (the element
or pseudo-element that generated the ‘<code
class=css>::outside</code>’ pseudo-element).
<p>For example, the following rules:
<pre>
span { content: "span"; }
span::before { content: "B"; }
span::outside(1) { display: inline; }
span::outside(1)::before { content: "A"; }
span::outside(2) { display: inline; }
span::outside(2)::after { content: "C"; }
</pre>
<p>...would result in the following rendering objects (including
construction lines for clarity):
<pre>
,--------------------------------. <-- border of ::outside(2)
| ,----------------------. | <-- border of ::outside(1)
| | ,---. ,-+---+------. | ,---. | <-- border of span, ::before,
| | | A | | | B | span | | | C | | and ::after boxes
| | `---' `-+---+------' | `---' |
| `----------------------' |
`--------------------------------'
</pre>
<p>This can be used to leave markers in the flow, as in: