-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathOverview.html
More file actions
4267 lines (3134 loc) · 135 KB
/
Overview.html
File metadata and controls
4267 lines (3134 loc) · 135 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">
<html lang=en>
<head>
<title>CSS3 Backgrounds and Borders 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">
<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--></p>
<h1 id=css-backgrounds>CSS Backgrounds and Borders Module Level 3</h1>
<h2 class="no-num no-toc" id=longstatus>Editor's Draft 4 April 2008</h2>
<dl>
<dt>This version:
<dd><a
href="http://www.w3.org/TR/2008/ED-css3-background-20080404">http://www.w3.org/TR/2008/ED-css3-background-20080404</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-background">http://www.w3.org/TR/css3-background</a>
<dt>Previous versions:
<dd><a
href="http://www.w3.org/TR/2005/WD-css3-background-20050216">http://www.w3.org/TR/2005/WD-css3-background-20050216</a>
<dd><a
href="http://www.w3.org/TR/2002/WD-css3-border-20021107">http://www.w3.org/TR/2002/WD-css3-border-20021107</a>
<dt id=editors-list>Editors:
<dd><a href="mailto:frederick.boland@nist.gov">Tim Boland</a> (<a
href="http://www.nist.gov/">NIST</a>)
<dd><a href="mailto:bert@w3.org">Bert Bos</a> (<a
href="http://www.w3.org/">W3C</a>)
<dd><a href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a>
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2008 <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>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 borders and
backgrounds. 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 borders consisting of images, boxes with multiple
backgrounds, boxes with rounded corners and boxes with shadows.
<p>This module replaces two earlier drafts: CSS3 Backgrounds and CSS3
Border.
<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">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-background” in the subject, preferably like this:
“[<!---->css3-background<!---->] <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-->
<p><strong>Not all the corrections and clarifications in the revised
edition of CSS2 <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a> have been applied to this
draft yet. In case of conflict (other than on properties and values that
are clearly new to CSS3), CSS 2.1 probably represents the intention
of the CSS WG better than this draft.</strong>
<h2 class="no-num no-toc" id=contents>Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#dependencies"><span class=secno>1. </span>Dependencies with
other CSS 3 Modules</a>
<li><a href="#context"><span class=secno>2. </span>Context</a>
<ul class=toc>
<li><a href="#modularization"><span class=secno>2.1
</span>Modularization of CSS</a>
<li><a href="#changesFromCSS2"><span class=secno>2.2 </span>Changes from
CSS 2.1</a>
</ul>
<li><a href="#the-layout"><span class=secno>3. </span>The layout model of
backgrounds and borders</a>
<li><a href="#background"><span class=secno>4. </span>Background
properties</a>
<ul class=toc>
<li><a href="#the-background-color"><span class=secno>4.1 </span>The
‘<span class=property>background-color</span>’ property</a>
<li><a href="#the-background-image"><span class=secno>4.2 </span>The
‘<span class=property>background-image</span>’ property</a>
<li><a href="#the-background-repeat"><span class=secno>4.3 </span>The
‘<span class=property>background-repeat</span>’
property</a>
<li><a href="#the-background-attachment"><span class=secno>4.4
</span>The ‘<span
class=property>background-attachment</span>’ property</a>
<li><a href="#the-background-position"><span class=secno>4.5 </span>The
‘<span class=property>background-position</span>’
property</a>
<li><a href="#the-background-clip"><span class=secno>4.6 </span>The
‘<span class=property>background-clip</span>’ property</a>
<li><a href="#the-background-origin"><span class=secno>4.7 </span>The
‘<span class=property>background-origin</span>’
property</a>
<li><a href="#the-background-size"><span class=secno>4.8 </span>The
‘<span class=property>background-size</span>’ property</a>
<li><a href="#the-background-break"><span class=secno>4.9 </span>The
‘<span class=property>background-break</span>’ property</a>
<li><a href="#layering"><span class=secno>4.10 </span>Layering multiple
background images</a>
<li><a href="#the-background"><span class=secno>4.11 </span>The
‘<span class=property>background</span>’ property</a>
<li><a href="#the-background0"><span class=secno>4.12 </span>The
background of the canvas</a>
</ul>
<li><a href="#border"><span class=secno>5. </span>Border properties</a>
<ul class=toc>
<li><a href="#the-border-color"><span class=secno>5.1 </span>The
‘<span class=property>border-color</span>’ properties</a>
<li><a href="#the-border-style"><span class=secno>5.2 </span>The
‘<span class=property>border-style</span>’ properties</a>
<li><a href="#the-border-width"><span class=secno>5.3 </span>The
‘<span class=property>border-width</span>’ properties</a>
<li><a href="#the-border-image"><span class=secno>5.4 </span>The
‘<span class=property>border-image</span>’ property</a>
<li><a href="#the-border-radius"><span class=secno>5.5 </span>The
‘<span class=property>border-radius</span>’ properties</a>
<li><a href="#the-border-break"><span class=secno>5.6 </span>The
‘<span class=property>border-break</span>’ property</a>
<li><a href="#the-border-shorthands"><span class=secno>5.7 </span>The
‘<span class=property>border-top</span>’, ‘<span
class=property>border-bottom</span>’, ‘<span
class=property>border-right</span>’, ‘<span
class=property>border-left</span>’, and ‘<span
class=property>border</span>’ properties</a>
<li><a href="#the-box-shadow"><span class=secno>5.8 </span>The
‘<span class=property>box-shadow</span>’ property</a>
</ul>
<li><a href="#definitions"><span class=secno>6. </span>Definitions</a>
<ul class=toc>
<li><a href="#profiles"><span class=secno>6.1 </span>Profiles</a>
<li><a href="#conformance"><span class=secno>6.2 </span>Conformance</a>
<li><a href="#glossary"><span class=secno>6.3 </span>Glossary</a>
<li><a href="#exit"><span class=secno>6.4 </span>CR exit criteria</a>
</ul>
<li><a href="#acknowledgments"><span class=secno>7.
</span>Acknowledgments</a>
<li><a href="#references"><span class=secno>8. </span>References</a>
<ul class=toc>
<li class=no-num><a href="#normative">Normative references</a>
<li class=no-num><a href="#other">Other references</a>
</ul>
<li class=no-num><a href="#property">Property index</a>
<li class=no-num><a href="#index">Index</a>
</ul>
<!--end-toc-->
<h2 id=dependencies><span class=secno>1. </span>Dependencies with other CSS
3 Modules</h2>
<ul><!--<li>General Syntax [!CSS3SYN]-->
<li>Values and Units <a href="#CSS3VAL"
rel=biblioentry>[CSS3VAL]<!--{{!CSS3VAL}}--></a> (in particular the types
<dfn id=ltlengthgt><var><length></var></dfn>, <dfn
id=lturigt><var><uri></var></dfn> and <dfn
id=ltpercentagegt><var><percentage></var></dfn>)
<!--<li>Cascading and Inheritance [!CSS3CASCADE]-->
<!--<li>Box Model [!CSS3BOX]-->
<li>CSS 2.1 <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a> (in particular the box model
of section 8.1)
<li>Color module <a href="#CSS3COLOR"
rel=biblioentry>[CSS3COLOR]<!--{{!CSS3COLOR}}--></a> (in particular the
<dfn id=ltcolorgt><var><color></var></dfn> type)
<!--<li>User Interface [? check]-->
<!--<li>Absolute Positioning Module [!CSS3POS]] (in particular the
section “Elaborate
description of Stacking Contexts”)-->
<!--<li>Paged Media [!CSS3PAGE] (breaking elements across
pages)-->
</ul>
<h2 id=context><span class=secno>2. </span>Context</h2>
<h3 id=modularization><span class=secno>2.1 </span>Modularization of CSS</h3>
<p>The members of the Cascading Style Sheets (CSS) Working Group proposed
during the Clamart meeting to modularize the CSS specification.
<p>This modularization, and the externalization of the general syntax, of
CSS reduces the size of the specification and allows new types of
specifications to use selectors and/or CSS general syntax.
<p>This module will have its own test suite (on the <a
href="/Style/CSS/Test/">CSS test suites page</a>) with several tests per
concept introduced in this document, as well as tests for multiple
concepts used together. This test suite will not consist of full
conformance tests, but is intended to ensure interoperability between
implementations and forms part of the CR exit criteria.
<p>See the section on <a href="#conformance">Conformance</a> for the role
of modules in the implementation requirements for <a href="#ua"
title=UA>UAs</a>.
<h3 id=changesFromCSS2><span class=secno>2.2 </span>Changes from CSS 2.1</h3>
<p class=issue>[This section needs to be revised.]
<p>‘<a class=property
href="#background-clip">Background-clip</a>’, ‘<a
class=property href="#background-break">background-break</a>’, and
‘<a class=property
href="#background-origin">background-origin</a>’ are new. Also there
are changes to the ‘<a class=property
href="#background0">background</a>’ shorthand property.
<p>‘<a class=property
href="#background-attachment">Background-attachment</a>’ has a new
value ‘<code class=css><a href="#local">local</a></code>’.
<p>The background can now have multiple images. As a consequence, several
properties now accept a comma-separated list of values.
<p>‘<a class=property href="#box-shadow">Box-shadow</a>’,
‘<a class=property href="#border-image">border-image</a>’,
‘<a class=property href="#border-break">border-break</a>’ and
‘<a class=property href="#border-radius">border-radius</a>’
are new.
<h2 id=the-layout><span class=secno>3. </span>The layout model of
backgrounds and borders</h2>
<p>(This section is not normative.)
<p>When elements are rendered according to the CSS box model <a
href="#CSS3BOX" rel=biblioentry>[CSS3BOX]<!--{{CSS3BOX}}--></a>, each
element is either not displayed at all, or formatted as one or more
rectangular boxes. Each box has a rectangular content area, a band of
padding around the content, a border around the padding, and a margin
outside the border. (The margin may actually be negative, but margins have
no influence on the background and border.)
<div class=figure>
<p><img alt="Diagram of a typical box, showing the content, padding,
border and margin areas" src=box></p>
<p class=caption>The various areas and edges of a typical box. (This
diagram is explained in the CSS3 Box Module <a href="#CSS3BOX"
rel=biblioentry>[CSS3BOX]<!--{{CSS3BOX}}--></a>.)</p>
</div>
<p>The child elements of an element usually create boxes of their own, that
are placed inside the content area of their parent, although they may also
be placed outside it.
<p>The reason an element may result in more than one box, is that elements
may be broken at the end of a line (for inline elements), at the end of a
column or at the end of a page and create further boxes in the next line,
column or page.
<p>The properties of this module deal with the contents of the border area
and with the background of the content, padding and border areas.
<p>That background may be fully transparent (the default), or it may be
filled with a color, one or more images, or both images and color. The
background properties specify what color ( ‘<a class=property
href="#background-color">background-color</a>’) and images (
‘<a class=property
href="#background-image">background-image</a>’) to use, where they
are placed ( ‘<a class=property
href="#background-position">background-position</a>’), whether they
are repeated or scaled ( ‘<a class=property
href="#background-repeat">background-repeat</a>’, ‘<a
class=property href="#background-size">background-size</a>’), etc.
<p>The ‘<a class=property
href="#border-image">border-image</a>’ property can also define a
background image, which, if present, is added on top of that of the
background properties.
<p>The border can either be a predefined style (solid line, double line,
dotted line, pseudo-3D border, etc.) or it can be an image. In the former
case, three properties define the style of the four border sides (
‘<a class=property href="#border-style">border-style</a>’),
color ( ‘<a class=property
href="#border-color">border-color</a>’) and thickness ( ‘<a
class=property href="#border-width">border-width</a>’). In the
latter case, the sides and corners are taken from the sides and corners of
an image specified with ‘<a class=property
href="#border-image">border-image</a>’. The image can be sliced,
scaled and stretched in various ways to fit the size of the border.
<p>If an element is broken into multiple boxes, ‘<a class=property
href="#border-break">border-break</a>’ and ‘<a class=property
href="#background-break">background-break</a>’ define how the
borders and background are divided over the various boxes.
<p>There is also another kind of decoration that can be added to an
element: a drop shadow, via the ‘<a class=property
href="#box-shadow">box-shadow</a>’ property.
<h2 id=background><span class=secno>4. </span>Background properties</h2>
<h3 id=the-background-color><span class=secno>4.1 </span>The ‘<a
class=property href="#background-color">background-color</a>’
property</h3>
<table class=propdef id=name->
<tbody>
<tr>
<th>Name:
<td><dfn id=background-color>background-color</dfn>
<tr>
<th>Value:
<td><color> [ / <color> ]?
<tr>
<th>Initial:
<td>transparent
<tr>
<th>Applies to:
<td>all elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>as specified
</table>
<p>This property sets the background color of an element. Valid color
values are defined in the Color Module <a href="#CSS3COLOR"
rel=biblioentry>[CSS3COLOR]<!--{{!CSS3COLOR}}--></a>.
<p class=note>Note that the color is drawn behind any background images,
see ‘<a class=property
href="#background-image">background-image</a>’.
<p>If the value contains a second color, that color is used instead of the
first in the case the element's bottom-most background image, if any,
cannot be drawn. The color is called the “fallback color.”
<div class=example>
<p>Example:</p>
<pre>h1 { background-color: #F00 }
div { background-color: transparent / yellow }</pre>
</div>
<h3 id=the-background-image><span class=secno>4.2 </span>The ‘<a
class=property href="#background-image">background-image</a>’
property</h3>
<table class=propdef id=name-0>
<tbody>
<tr>
<th>Name:
<td><dfn id=background-image>background-image</dfn>
<tr>
<th>Value:
<td>[ <var><a href="#lturigt0"><uri></a></var> | none ] [ , [
<var><a href="#lturigt0"><uri></a></var> | none ] ]*
<tr>
<th>Initial:
<td>none
<tr>
<th>Applies to:
<td>all elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>as specified, but with URIs made absolute
</table>
<p>This property sets the background image(s) of an element. Images are
drawn with the first specified one on top (closest to the user) and each
subsequent image behind the previous one. The ‘<a class=property
href="#background-color">background-color</a>’ is painted below all
the images.
<p>A value of <span class=css title=bg-none>‘<span
class=property>none</span>’</span> counts as an image but draws
nothing. An image that is empty (zero width or zero height), that fails to
download, or that cannot be displayed (e.g., because it is not in a
supported image format) has the same effect as <span class=css
title=bg-image-none>‘<span class=property>none</span>’</span>.
<p>See the section <a href="#layering">“Layering multiple background
images”</a> for how each image is tiled or stretched.
<div class=example>
<p style=display:none>Example:</p>
<pre>
body { background-image: url("marble.svg") }
p { background-image: none }
div { background-image: url(tl.png), url(tr.png) }
</pre>
</div>
<p class=note>Implementations may optimize by not downloading and drawing
images that are not visible (e.g., because they are behind other, fully
opaque images).
<h3 id=the-background-repeat><span class=secno>4.3 </span>The ‘<a
class=property href="#background-repeat">background-repeat</a>’
property</h3>
<table class=propdef id=name-1>
<tbody>
<tr>
<th>Name:
<td><dfn id=background-repeat>background-repeat</dfn>
<tr>
<th>Value:
<td><var><a href="#ltrepeatgt"><repeat></a></var> [ , <var><a
href="#ltrepeatgt"><repeat></a></var> ]*
<tr>
<th>Initial:
<td>repeat
<tr>
<th>Applies to:
<td>all elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>as specified
</table>
<p>Specifies how images are tiled. The type <dfn
id=ltrepeatgt><var><repeat></var></dfn> stands for: repeat-x |
repeat-y | [repeat | space | round | no-repeat]{1,2}.
<p>See the section <a href="#layering">“Layering multiple background
images”</a> for how each comma-separated value is applied to each image
of the ‘<a class=property
href="#background-image">background-image</a>’ property.
<p>The tiling and positioning of the background image on inline elements is
described under the ‘<a class=property
href="#background-break">background-break</a>’ property.
<p>Single values for <var><a href="#ltrepeatgt"><repeat></a></var>
have the following meanings:
<dl>
<dt><dfn id=repeat-x>repeat-x</dfn>
<dd> Equivalent to ‘<code class=css>repeat no-repeat</code>’.
<dt><dfn id=repeat-y>repeat-y</dfn>
<dd> Equivalent to ‘<code class=css>no-repeat repeat</code>’
<dt><a class=css href="#repeat">repeat</a>
<dd> Equivalent to ‘<code class=css>repeat repeat</code>’
<dt><a class=css href="#no-repeat">no-repeat</a>
<dd> Equivalent to ‘<code class=css>no-repeat
no-repeat</code>’
<dt><a class=css href="#space">space</a>
<dd> Equivalent to ‘<code class=css>space space</code>’
<dt><a class=css href="#round">round</a>
<dd> Equivalent to ‘<code class=css>round round</code>’
</dl>
<p>If a <var><a href="#ltrepeatgt"><repeat></a></var> value has two
keywords, the first one is for the horizontal direction, the second for
the vertical one, as follows:
<dl>
<dt><dfn id=repeat>repeat</dfn>
<dd> The image is repeated in this direction as often as needed to cover
the area. The image is clipped at the border or padding edge (depending
on ‘<a class=property
href="#background-clip">background-clip</a>’).
<dt><dfn id=no-repeat>no-repeat</dfn>
<dd> The image is not repeated in this direction. If it is too large, the
image is clipped at the border or padding edge (depending on ‘<a
class=property href="#background-clip">background-clip</a>’).
<dt><dfn id=space>space</dfn>
<dd> The image is repeated as often as it will fit without being clipped
and then the images are spaced out to fill the area. The first and last
images touch the edges. The value of ‘<a class=property
href="#background-position">background-position</a>’ for this
direction is ignored. <span class=issue>What if there is only room for
one image? What if there is room for no image at all?</span>
<dt><dfn id=round>round</dfn>
<dd> The image is repeated as often as it will fit. If it doesn't fit a
whole number of times, it is reduced in size until it does. See
explanation under ‘<a class=property
href="#background-size">background-size</a>’.
</dl>
<p>Unless one of the two keywords is ‘<code class=css><a
href="#no-repeat">no-repeat</a></code>’, the whole background will
be tiled, i.e., not just one vertical strip and one horizontal strip.
<div class=example>
<p style=display:none>Example(s):</p>
<pre>
body {
background: white url("pendant.png");
background-repeat: repeat-y;
background-position: center;
}
</pre>
<div class=figure>
<p><img alt="A centered background image, with copies repeated up and
down the border, padding and content areas."
src=bg-repeat><!--<SPAN class="dlink"> <A
name="img-bg-repeat" href="images/longdesc/bg-repeat-desc.html"
title="Long description for background pattern">[D]</A></SPAN>-->
</p>
<p class=caption>The effect of ‘<a class=property
href="#repeat-y">repeat-y</a>’: One copy of the background image
is centered, and other copies are put above and below it to make a
vertical band behind the element.</p>
</div>
</div>
<div class=example>
<p style=display:none>Example(s):</p>
<pre>
body {
background-image: url(dot.png) white;
background-repeat: space
}
</pre>
<div class=figure>
<p><img alt="Image of an element with a dotted background" src=bg-space></p>
<p class=caption>The effect of ‘<a class=property
href="#space">space</a>’: the image of a dot is tiled to cover the
whole background and the images are equally spaced.</p>
</div>
</div>
<h3 id=the-background-attachment><span class=secno>4.4 </span>The ‘<a
class=property
href="#background-attachment">background-attachment</a>’ property</h3>
<table class=propdef id=name-2>
<tbody>
<tr>
<th>Name:
<td><dfn id=background-attachment>background-attachment</dfn>
<tr>
<th>Value:
<td><dfn id=scroll>scroll</dfn> | <dfn id=fixed>fixed</dfn> | <dfn
id=local>local</dfn> [, scroll | fixed | local]*
<tr>
<th>Initial:
<td>scroll
<tr>
<th>Applies to:
<td>all elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>as specified
</table>
<p>If background images are specified, this property specifies whether they
are fixed with regard to the <em class=index id=viewport>viewport</em> (
‘<code class=css><a href="#fixed">fixed</a></code>’) or scroll
along with the element ( ‘<code class=css><a
href="#scroll">scroll</a></code>’ and ‘<code class=css><a
href="#local">local</a></code>’).
<p>See the section <a href="#layering">“Layering multiple background
images”</a> for how each comma-separated value is applied to each image
of the ‘<a class=property
href="#background-image">background-image</a>’ property.
<p>The difference between ‘<code class=css><a
href="#scroll">scroll</a></code>’ and ‘<code class=css><a
href="#local">local</a></code>’ is only visible when the element has
a scrolling mechanism (see ‘<span
class=property>overflow</span>’): in the case of ‘<code
class=css><a href="#scroll">scroll</a></code>’, the background does
not scroll with the element's content. (It is attached to the element's
border, as it were.) In the case of ‘<code class=css><a
href="#local">local</a></code>’, the background scrolls along with
the element's content. In this case, the background behind the element's
border (if any) scrolls as well, even though the border itself does not
scroll with the contents.
<p>Even if the image is fixed, it is still only visible when it is in the
content, padding, or border area of the element. Thus, unless the image is
tiled, it may be invisible.
<div class=example>
<p style=display:none>Example(s):</p>
<p>This example creates an infinite vertical band that remains “glued”
to the viewport when the element is scrolled.</p>
<pre>
body {
background: red url("pendant.gif");
background-repeat: repeat-y;
background-attachment: fixed;
}
</pre>
</div>
<p>User agents that do not support ‘<code class=css><a
href="#fixed">fixed</a></code>’ backgrounds (for example due to
limitations of the hardware platform) should ignore declarations with the
keyword ‘<a class=property href="#fixed">fixed</a>’. For
example:
<pre class=example>
body {
/* For all UAs: */
background: white url(paper.png) scroll;
/* For UAs that do fixed backgrounds: */
background: white url(ledger.png) fixed;
}
h1 {
/* For all UAs: */
background: silver;
/* For UAs that do fixed backgrounds: */
background: url(stripe.png) fixed, white url(ledger.png) fixed;
}
</pre>
<h3 id=the-background-position><span class=secno>4.5 </span>The ‘<a
class=property href="#background-position">background-position</a>’
property</h3>
<table class=propdef id=name-3>
<tbody>
<tr>
<th>Name:
<td><dfn id=background-position>background-position</dfn>
<tr>
<th>Value:
<td><var><a href="#ltbg-positiongt"><bg-position></a></var> [ ,
<var><a href="#ltbg-positiongt"><bg-position></a></var> ]*
<tr>
<th>Initial:
<td>0% 0%
<tr>
<th>Applies to:
<td>all elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>refer to size of element's box <em>minus</em> size of background
image; see text
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>for <length> the absolute value, otherwise a percentage
</table>
<p>If background images have been specified, this property specifies their
initial position. The section <a href="#layering">“Layering multiple
background images”</a> defines to which image of ‘<a
class=property href="#background-image">background-image</a>’ each
of the comma-separated values applies.
<p>The <dfn id=ltbg-positiongt><var><bg-position></var></dfn> stands
for: [ [ <var><a href="#ltpercentagegt0"><percentage></a></var> |
<var><a href="#ltlengthgt0"><length></a></var> | left | center |
right ] [ <var><a href="#ltpercentagegt0"><percentage></a></var> |
<var><a href="#ltlengthgt0"><length></a></var> | top | center |
bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ]
<p id=bg-area-edge>Each <var><a
href="#ltbg-positiongt"><bg-position></a></var> specifies an offset
from the top left corner of either the viewport (if ‘<a
class=property
href="#background-attachment">background-attachment</a>’ is
‘<code class=css><a href="#fixed">fixed</a></code>’ for this
image) or the box given by ‘<a class=property
href="#background-origin">background-origin</a>’ (if ‘<a
class=property
href="#background-attachment">background-attachment</a>’ is not
‘<code class=css><a href="#fixed">fixed</a></code>’).
<p>If only one percentage or length value is given, it sets the horizontal
offset only, and the vertical offset will be 50%. If two values are given,
the horizontal offset comes first. Combinations of keyword, length and
percentage values are allowed, (e.g., ‘<code class=css>50%
2cm</code>’ or ‘<code class=css>center 2cm</code>’ or
‘<code class=css>center 10%</code>’). For pairs of keyword and
non-keyword values, ‘<span class=property>left</span>’ and
‘<span class=property>right</span>’ may only be used as the
first value, and ‘<span class=property>top</span>’ and
‘<span class=property>bottom</span>’ may only be used as the
second value. Negative positions are allowed.
<p>The keywords are equivalent to percentages, as follows:
<dl>
<dt>top left,
<dt>left top
<dd> Same as ‘<code class=css>0% 0%</code>’.
<dt>top,
<dt>top center,
<dt>center top
<dd> Same as ‘<code class=css>50% 0%</code>’.
<dt>right top,
<dt>top right
<dd> Same as ‘<code class=css>100% 0%</code>’.
<dt>left,
<dt>left center,
<dt>center left
<dd> Same as ‘<code class=css>0% 50%</code>’.
<dt>center,
<dt>center center
<dd> Same as ‘<code class=css>50% 50%</code>’.
<dt>right,
<dt>right center,
<dt>center right
<dd> Same as ‘<code class=css>100% 50%</code>’.
<dt>bottom left,
<dt>left bottom
<dd> Same as ‘<code class=css>0% 100%</code>’.
<dt>bottom,
<dt>bottom center,
<dt>center bottom
<dd> Same as ‘<code class=css>50% 100%</code>’.
<dt>bottom right,
<dt>right bottom
<dd> Same as ‘<code class=css>100% 100%</code>’.
</dl>
<p>A percentage for the horizontal offset is relative to (<var>width of
element</var> - <var>width of background image</var>). A percentage for
the vertical offset is relative to (<var>height of element</var> -
<var>height of background image</var>), where the size of the image is the
size given by ‘<a class=property
href="#background-size">background-size</a>’ and the size of the
element is the size of the box given by ‘<a class=property
href="#background-origin">background-origin</a>’.
<p>If the element is rendered as multiple boxes (e.g., inline boxes on
several lines, boxes on several pages), the ‘<a class=property
href="#background-break">background-break</a>’ property determines
which box(es) to use.
<div class=example>
<p>For example, with a value pair of ‘<code class=css>0%
0%</code>’, the upper left corner of the image is aligned with the
upper left corner of, usually, the box's <em>padding edge</em>. A value