-
Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathOverview.src.html
3550 lines (3049 loc) · 127 KB
/
Overview.src.html
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>
<meta http-equiv=content-type content="text/html; charset=utf-8">
<title>CSS Backgrounds and Borders Module Level 3</title>
<link rel=contents href="#contents">
<link rel=index href="#index">
<link rel="stylesheet" type="text/css" href="../default.css">
<style type="text/css">
.prod { font-family: inherit; font-size: inherit }
pre.prod { white-space: pre-wrap; margin: 1em 0 1em 2em }
code { font-size: inherit; }
pre { text-align: left; }
#box-shadow-samples td { background: white; color: black; }
.css::before, .css::after, .property::before, .property::after { content: none !important;}
</style>
<link rel="stylesheet" type="text/css"
href="https://www.w3.org/StyleSheets/TR/W3C-WD.css">
<script defer="defer"
src="images/https://test.csswg.org/harness/annotate.js#css-backgrounds-3_dev"
type="text/javascript"></script>
</head>
<body>
<div class="head">
<!--logo-->
<h1>CSS Backgrounds and Borders Module Level 3</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This version:
<dd><a href="[VERSION]">[VERSION]</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-background/">[LATEST]</a>
<dt>Latest editor's draft:
<dd><a href="http://dev.w3.org/csswg/css3-background/">http://dev.w3.org/csswg/css3-background/</a>
<dt>Previous version:
<dd><a href="http://www.w3.org/TR/2014/CR-css3-background-20140909/">http://www.w3.org/TR/2014/CR-css3-background-20140909/</a>
<dt>Issue Tracking:
<dd><a href="http://www.w3.org/Style/CSS/Tracker/products/11">http://www.w3.org/Style/CSS/Tracker/products/11</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-backgrounds%5D%20feedback"
>www-style@w3.org</a>
with subject line “<kbd>[css-backgrounds]
<var>… message topic …</var></kbd>”
(<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/"
>archives</a>)
<dt id="editors-list">Editors:
<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> (Mozilla)
<dd><a href="mailto:brad.kemper@gmail.com">Brad Kemper</a> (Invited Expert)
<dt>Latest test suite:
<dd><a href="http://test.csswg.org/suites/css3-background/nightly-unstable/">http://test.csswg.org/suites/css3-background/nightly-unstable/</a>
</dl>
<!--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
<span>documents</span> (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 [[!CSS21]], which builds on CSS level 1
[[CSS1]]. 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>
<!--status-->
<p>The following features are at-risk and may be dropped at the
end of the CR period if there has not been enough interest from
implementers: animatability of 'box-shadow'
<p>The CSS WG maintains an <a href="http://www.w3.org/Style/CSS/Tracker/products/11">issues
list</a> for this module. A <a href="http://www.w3.org/Style/CSS/Test/">test
suite</a> and implementation report for CSS Backgrounds and Borders Level 3
will be developed during the Candidate Recommendation phase, which will last
a minimum of three months, and at least until 25 July 2012. See the
section <a href="#exit">“CR exit criteria”</a> for more details.
<p>The changes to this specification since the previous drafts are
listed in the <a href="#changes" >“Changes”</a> section.
<h2 class="no-num no-toc" id="contents">Table of contents</h2>
<!--toc-->
<h2 id="introduction">Introduction</h2>
<p><em>This subsection is not normative.</em>
<p>When elements are rendered according to the
<a href="http://www.w3.org/TR/CSS21/box.html">CSS box model</a> [[!CSS21]],
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 src="images/box" alt="Diagram of a typical box, showing the
content, padding, border and margin areas">
<p class="caption">The various areas and edges of a typical box.
(This diagram is explained in the CSS2.1 Box Model chapter [[!CSS21]].)
</div>
<p>The properties of this module deal with the decoration of the border
area and with the background of the content, padding and border areas.
Additionally the box may be given a "drop-shadow" effect with the
'box-shadow' property.
<p>If an element is broken into multiple boxes, 'box-decoration-break' [[CSS3-BREAK]]
defines how the borders and background are divided over the various boxes.
(An element can result in more than one box if it is broken at the
end of a line, at the end of a column or at the end of a page; and
continued in the next line, column or page.)
<p>The relative stacking order of backgrounds, borders, and shadows
is given in this module. For how these layers interact with other
rendered content, see Appendix E “Elaborate description of Stacking
Contexts” in [[!CSS21]].
<h2 id="values">
Values and Interactions</h2>
<p>This specification follows the
<a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
definition conventions</a> from [[!CSS21]].
<h3 id="placement">
Module Interactions</h3>
<p>This module replaces and extends the background and border
features defined in [[!CSS21]] sections 8.5 and 14.2.
<p>All properties in this module apply to the
<a href="http://www.w3.org/TR/CSS21/selector.html#first-letter"><code>::first-letter</code></a>
pseudo-element. The <a href="#backgrounds">background properties</a>
and <a href="#corners">border-radius properties</a> also apply to the
<a href="http://www.w3.org/TR/CSS21/selector.html#first-line-pseudo"><code>::first-line</code></a>
pseudo-element. The UA may (but is not required to) apply the
<a href="#border-images">border-image</a> or 'box-shadow' properties to
<code>::first-line</code>. The UA must not apply the
<a href="#borders">border-color/style/width properties</a> to
<code>::first-line</code>. [[!CSS21]]
<h3 id=value-types>
Value Types</h3>
<p>The <dfn><var><image></var></dfn> value type is defined by this
specification as <code class=prod><var><image></var> =
<var><uri></var></code>. Other value types are defined in
CSS Level 2 Revision 1 [[!CSS21]].
Other CSS modules may expand the definitions of these value types: for
example [[CSS3COLOR]], when combined with this module, expands the
definition of the <color> value type as used in this specification.
Similarly, [[CSS3-IMAGES]], when combined with this module,
expands the definition of <var><image></var> as used in this specification.
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the
<a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.
<h3 id=animations>Animated Values</h3>
<p><!-- <a href="http://www.w3.org/Style/CSS/Tracker/issues/210"
>ISSUE-210.]</a> --> It is expected that CSS will include ways to
animate transitions between styles. (The
section <a
href="http://www.w3.org/TR/css3-transitions/#animatable-types"
>“Animation of property types”</a> of the <cite>CSS Transitions
module</cite> [[CSS3-TRANSITIONS]] is expected to define how different
kinds of values are interpolated during a transition.) In anticipation
of that, this module includes a line “Animatable” for each property,
which specifies whether and how values of the property can be animated.
<h2 id="backgrounds">
Backgrounds</h2>
<p>Each box has a background layer that may be fully transparent (the
default), or filled with a color and/or one or more images. The background
properties specify what color ('background-color')
and images ('background-image') to use,
and how they are sized, positioned, tiled, etc.
<p>The background properties are not inherited, but the parent box's
background will shine through by default because of the initial
'transparent' value on 'background-color'.
<h3 id="layering">
Layering Multiple Background Images</h3>
<p>The background of a box can have multiple <span
class=index>layers</span> in CSS3. The number
of layers is determined by the number of comma-separated values in the
'background-image' property. Note that a value of 'none' still creates
a layer.
<p>Each of the images is sized, positioned, and tiled according to
the corresponding value in the other background properties. The lists
are matched up from the first value: excess values at the end are not
used. If a property doesn't have enough comma-separated values to match
the number of layers, the <span>UA</span> must calculate its used
value by repeating
the list of values until there are enough.
<div class="example">
<p>For example, this set of declarations:
<pre>
background-image: url(flower.png), url(ball.png), url(grass.png);
background-position: center center, 20% 80%, top left, bottom right;
background-origin: border-box, content-box;
background-repeat: no-repeat;
</pre>
<p>has exactly the same effect as this set with the extra position
dropped and the missing values for 'background-origin' and
'background-repeat' filled in (emphasized for clarity):
<pre>
background-image: url(flower.png), url(ball.png), url(grass1.png);
background-position: center center, 20% 80%, top left;
background-origin: border-box, content-box<strong>, border-box</strong>;
background-repeat: no-repeat<strong>, no-repeat, no-repeat</strong>;
</pre>
</div>
<p>The first image in the list is the layer closest to the user,
the next one is painted behind the first, and so on. The background
color, if present, is painted below all of the other layers.
<p class="note">Note that the <a href="#border-images">border-image properties</a>
can also define a background image, which, if present, is painted on top of
the background created by the background properties.
<h3 id="the-background-color">Base Color: the 'background-color' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>background-color</dfn>
<tr>
<th><a href="#values">Value</a>:
<td><var><color></var>
<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>the computed color
<tr>
<th>Animatable:
<td>as <a href="http://www.w3.org/TR/css3-transitions/#animtype-color">color</a>
</table>
<p>This property sets the <span class=index
title="color!!background">background color</span> of an element. The
color is drawn behind any background images.
<div class="example">
<p>Example:
<pre>h1 { background-color: #F00 } /* Sets background to red. */</pre>
</div>
<p>The background color is clipped according to the 'background-clip'
value associated with the bottom-most background image layer.
<h3 id="the-background-image">Image Sources: the 'background-image' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>background-image</dfn>
<tr>
<th><a href="#values">Value</a>:
<td><var><bg-image></var>
[ , <var><bg-image></var> ]*
<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
<tr>
<th>Animatable:
<td>no
</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.
Where
<pre class=prod><dfn><var><bg-image></var></dfn> = <var><image></var> | none</pre>
<p>A value of <dfn title="''none''!!'background-image' value">''none''</dfn>
counts as an image layer 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) likewise counts as a layer but
draws nothing.
<p>See the section <a href="#layering">“Layering multiple background
images”</a> for how 'background-image' interacts with other
comma-separated background properties to form each background image
layer.
<p>When setting a background image, authors should also specify a
''background-color'' that will preserve contrast with the text for
when the image is unavailable.
<p>For accessibility reasons, authors should not use background images
as the sole method of conveying important information.
See <a href="http://www.w3.org/TR/2008/NOTE-WCAG20-TECHS-20081211/F3">Web
Content Accessibility Guideline F3</a> [[WCAG20]]. Images are not
accessible in non-graphical presentations, and background images
specifically might be turned off in high-contrast display modes.
<p class="note">Note that stylistic foreground images can be provided
in CSS with the
<a href="http://www.w3.org/TR/CSS21/generate.html#content">content</a>
property. (Semantically-important foreground images should be provided
in the document markup, e.g. with the <img> tag in HTML.)</p>
<p class="note"><a href="http://www.w3.org/TR/media-frags/#naming-space">Media fragments</a>
can be used to display a portion of an image. The
<a href="http://www.w3.org/TR/css3-images/">CSS Images</a> module
will provide fallback syntax for image formats and include additional
controls for image display.
<div class="example">
<p>Some examples specifying background images:</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">Tiling Images: the 'background-repeat' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>background-repeat</dfn>
<tr>
<th><a href="#values">Value</a>:
<td><var><repeat-style></var> [ , <var><repeat-style></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>A list, each item consisting of:
two keywords, one per dimension
<tr>
<th>Animatable:
<td>no
</table>
<p>Specifies how background images are tiled after they have been
<a href="#the-background-size">sized</a> and <a href="#the-background-position">positioned</a>.
Where
<pre class=prod><dfn><var><repeat-style></var></dfn> = repeat-x | repeat-y | [repeat | space | round | no-repeat]{1,2}</pre>
<p>Single values for <var><repeat-style></var> have the following
meanings:
<dl>
<dt><dfn>''repeat-x''</dfn>
<dd>
Computes to ''repeat no-repeat''.
<dt><dfn>''repeat-y''</dfn>
<dd>
Computes to ''no-repeat repeat''.
<dt>''repeat''
<dd>
Computes to ''repeat repeat''.
<dt>''space''
<dd>
Computes to ''space space''
<dt>''round''
<dd>
Computes to ''round round''
<dt>''no-repeat''
<dd>
Computes to ''no-repeat no-repeat''
</dl>
<p>If a <var><repeat-style></var> value has two keywords, the first
one is for the horizontal direction, the second for the vertical one,
as follows:
<dl>
<dt><dfn title="''repeat''!!'background-repeat' value">''repeat''</dfn>
<dd>
The image is repeated in this direction as often as needed to cover
the <span class=index>background painting area</span>.
<dt><dfn title="''space''!!'background-repeat' value">''space''</dfn>
<dd>
The image is repeated as often as will fit within the
<span class=index>background positioning area</span> without being
clipped and then the images are spaced out to fill the area. The
first and last images touch the edges of the area. If the <span
class=index>background
painting area</span> is larger than the background positioning area, then
the pattern repeats to fill the background painting area.
The value of 'background-position' for this direction
is ignored, unless there is not enough space for two copies of the
image in this direction, in which case only one image is placed and
'background-position' determines its position in this
direction.
<dt><dfn title="''round''!!'background-repeat' value">''round''</dfn>
<dd>
The image is repeated as often as will fit within the
<span class=index>background positioning area.</span> If it doesn't
fit a whole number of times, it is rescaled so that it does.
See the formula under 'background-size'. If the <span
class=index>background
painting area</span> is larger than the background positioning area, then
the pattern repeats to fill the background painting area.
<dt><dfn title="''no-repeat''!!'background-repeat' value">''no-repeat''</dfn>
<dd>
The image is placed once and not repeated in this direction.
</dl>
<p>Unless one of the two keywords is ''no-repeat'', the
whole background painting area will be tiled, i.e., not just one
vertical strip and one horizontal strip.
<div class="example">
<p style="display:none">Example(s):
<pre>
body {
background: white url("pendant.png");
background-repeat: repeat-y;
background-position: center;
}
</pre>
<div class="figure">
<p><img src="images/bg-repeat" alt="A centered background image, with
copies repeated up and down the border, padding and content
areas."><!--<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 class="caption">The effect of ''repeat-y'': 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.
</div>
</div>
<div class=example>
<p style="display:none">Example(s):
<pre>
body {
background-image: url(dot.png) white;
background-repeat: space
}
</pre>
<div class=figure>
<p><img src="images/bg-space" alt="Image of an element with a dotted background">
<p class=caption>The effect of 'space': the image of a dot is
tiled to cover the whole background and the images are equally
spaced.
</div>
</div>
<p>See the section <a href="#layering">“Layering multiple background
images”</a> for how 'background-repeat' interacts with other
comma-separated background properties to form each background image
layer.
<h3 id="the-background-attachment">Affixing Images: the 'background-attachment' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>background-attachment</dfn>
<tr>
<th><a href="#values">Value</a>:
<td><var><attachment></var> [ , <var><attachment></var> ]*
<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
<tr>
<th>Animatable:
<td>no
</table>
<p>If background images are specified, this property specifies whether
they are fixed with regard to the <em class="index">viewport</em>
(<dfn>''fixed''</dfn>) or scroll along with the element (<dfn>''scroll''</dfn>)
or its contents (<dfn>''local''</dfn>). The property's value is given as
a comma-separated list of <attachment> keywords where
<pre class=prod><dfn><var><attachment></var></dfn> = scroll | fixed | local</pre>
<dl>
<dt><dfn>fixed</dfn></dt>
<dd>The background is fixed with regard to the viewport. In paged
media where there is no viewport, a ''fixed'' background is fixed
with respect to the <a href="http://www.w3.org/TR/CSS21/page.html#page-box">page box</a>
and therefore replicated on every page.
<span class="note">Note that there is only one viewport per view.
Even if an element has a scrolling mechanism (see the 'overflow'
property [[!CSS21]]), a ''fixed'' background doesn't move with the
element.</span>
<dt><dfn>local</dfn></dt>
<dd>The background is fixed with regard to the element's contents:
if the element has a scrolling mechanism,
the background scrolls with the element's contents,
and the <i>background painting area</i> and <i>background positioning area</i>
are relative to the scrollable area of the element rather than to the border framing them.
Because the scrollable area does not include the border area,
for scrollable elements the ''border-box'' value of 'background-clip'
may be treated the same as ''padding-box''.</dd>
<dt><dfn>scroll</dfn></dt>
<dd>The background is fixed with regard to the element itself and
does not scroll with its contents. (It is effectively attached
to the element's border.)</dd>
</dl>
<p>Even if the image is fixed, it is still only visible when it is in
the <em class=index>background painting area</em> of the element or otherwise
unclipped. (See <a href="#special-backgrounds"> “The backgrounds of
special elements”</a> for the cases when background images are not
clipped.) Thus, unless the image is tiled, it may be invisible.
<div class="example">
<p>This example creates an infinite vertical band that remains
“glued” to the viewport when the element is scrolled.
<pre>
body {
background: red url("pendant.gif");
background-repeat: repeat-y;
background-attachment: fixed;
}
</pre>
</div>
<p>User agents that do not support ''fixed'' backgrounds (for
example due to limitations of the hardware platform) should ignore
declarations with the keyword ''fixed''. 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>
<p>See the section <a href="#layering">“Layering multiple background
images”</a> for how 'background-attachment' interacts with other
comma-separated background properties to form each background image
layer.
<h3 id="the-background-position">Positioning Images: the 'background-position' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>background-position</dfn>
<tr>
<th><a href="#values">Value</a>:
<td><var><position></var>
[ , <var><position></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 <span class=index>background positioning
area</span> <em>minus</em> size of background image; see text
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>A list, each item consisting of:
a pair of offsets (horizontal and vertical) from the top left origin
each given as a combination of an absolute length and a percentage
<tr>
<th>Animatable:
<td>as <a href="http://www.w3.org/TR/css3-transitions/#animtype-repeatable-list">repeatable list</a> of <a href="http://www.w3.org/TR/css3-transitions/#animtype-simple-list">simple list</a> of <a href="http://www.w3.org/TR/css3-transitions/#animtype-lpcalc">length, percentage, or calc</a>
</table>
<p>If background images have been specified, this property specifies
their initial position (after any <a href="#the-background-size">resizing</a>)
within their corresponding <span>background positioning area.</span>
<p>Where
<pre class=prod><dfn><var><position></var></dfn> = [
[ left | center | right | top | bottom | <var><percentage></var> | <var><length></var> ]
|
[ left | center | right | <var><percentage></var> | <var><length></var> ]
[ top | center | bottom | <var><percentage></var> | <var><length></var> ]
|
[ center | [ left | right ] [ <var><percentage></var> | <var><length></var> ]? ] &&
[ center | [ top | bottom ] [ <var><percentage></var> | <var><length></var> ]? ]
]</pre>
<p>If only one value is specified, the second value is assumed to be
''center''. If two values are given, a length or percentage as the first
value represents the horizontal position (or offset) and a length or
percentage as the second value represents the vertical position (or
offset). <var><percentage></var> and <var><length></var>
values here represent an offset of the top left corner
of the background image from the top left corner of the background
positioning area.
<p class="note">Note that a pair of keywords can be reordered while
a combination of keyword and length or percentage cannot.
So ''center left'' is valid while ''50% left'' is not.
<p>If three or four values are given, then
each <var><percentage></var> or<var><length></var>
represents an offset and must be preceded by a keyword,
which specifies from which edge the offset is given. For example,
''background-position: bottom 10px right 20px'' represents a
''10px'' vertical offset up from the bottom edge and a
''20px'' horizontal offset leftward from the right edge. If
three values are given, the missing offset is assumed to be zero.
<p>Positive values represent an offset <em>inward</em> from the edge of
the background positioning area. Negative values represent an offset
<em>outward</em> from the edge of the background positioning area.
<div class="example">
<p>The following declarations give the stated (horizontal, vertical)
offsets from the top left corner:</p>
<pre>
background-position: left 10px top 15px; /* 10px, 15px */
background-position: left top ; /* 0px, 0px */
background-position: 10px 15px; /* 10px, 15px */
background-position: left 15px; /* 0px, 15px */
background-position: 10px top ; /* 10px, 0px */
background-position: left top 15px; /* 0px, 15px */
background-position: left 10px top ; /* 10px, 0px */</pre>
</div>
<dl>
<dt><var><percentage></var>
<dd><p>A percentage for the horizontal offset is relative to (<var>width of
background positioning area</var> - <var>width of background image</var>).
A percentage for the vertical offset is relative to (<var>height
of background
positioning area</var> - <var>height of background image</var>), where the
size of the image is the size given by 'background-size'.
<div class=example>
<p>For example, with a value pair of ''0% 0%'', the upper left
corner of the image is aligned with the upper left corner of, usually,
the box's padding edge. A value pair of ''100% 100%'' places
the lower right corner of the image in the lower right corner of the
area. With a value pair of ''75% 50%'', the point 75% across
and 50% down the image is to be placed at the point 75% across and 50%
down the area.
<div class="figure">
<p><img alt="Diagram of image position within element" src="images/bg-pos.png">
<p class="caption">Diagram of the meaning of ''background-position: 75% 50%''.
</div>
</div>
<dt><var><length></var>
<dd>A length value gives a fixed length as the offset. For example, with a
value pair of ''2cm 1cm'', the upper left corner of the image
is placed 2cm to the right and 1cm below the upper left corner of the
background positioning area.
<dt><dfn title="''top''!!'background-position' value">''top''</dfn>
<dd>Computes to ''0%'' for the vertical position if one or two
values are given, otherwise specifies the top edge as the origin for the
next offset.
<dt><dfn title="''right''!!'background-position' value">''right''</dfn>
<dd>Computes to ''100%'' for the horizontal position if one or two
values are given, otherwise specifies the right edge as the origin
for the next offset.
<dt><dfn title="''bottom''!!'background-position' value">''bottom''</dfn>
<dd>Computes to ''100%'' for the vertical position if one or two
values are given, otherwise specifies the bottom edge as the origin
for the next offset.
<dt><dfn title="''left''!!'background-position' value">''left''</dfn>
<dd>Computes to ''0%'' for the horizontal position if one or two
values are given, otherwise specifies the left edge as the origin
for the next offset.
<dt><dfn title="''center''!!'background-position' value">''center''</dfn>
<dd>Computes to ''50%'' (''left 50%'') for the
horizontal position if the horizontal position is not otherwise
specified, or ''50%'' (''top 50%'') for the vertical position if
it is.
</dl>
<div class="example">
<p>The following 'background' shorthand declarations use keywords
to set 'background-position' to the stated percentage values.</p>
<pre>
body { background: url("banner.jpeg") right top } /* 100% 0% */
body { background: url("banner.jpeg") top center } /* 50% 0% */
body { background: url("banner.jpeg") center } /* 50% 50% */
body { background: url("banner.jpeg") bottom } /* 50% 100% */
</pre>
</div>
<div class="example">
<p>In the example below, the (single) image is placed in the lower-right
corner of the viewport.
<pre>
body {
background-image: url("logo.png");
background-attachment: fixed;
background-position: 100% 100%;
background-repeat: no-repeat;
}
</pre>
</div>
<div class=example>
<p>Background positions can also be relative to other corners than the
top left. E.g., the following puts the background image 10px from the
bottom and 3em from the right:
<pre>background-position: right 3em bottom 10px</pre>
</div>
<p>See the section <a href="#layering">“Layering multiple background
images”</a> for how 'background-position' interacts with
other comma-separated background properties to form each background
image layer.
<h3 id="the-background-clip">Painting Area: the 'background-clip' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>background-clip</dfn>
<tr>
<th><a href="#values">Value</a>:
<td><var><box></var> [ , <var><box></var> ]*
<tr>
<th>Initial:
<td>border-box
<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
<tr>
<th>Animatable:
<td>no
</table>
<p>Determines the <dfn id="background-painting-area">background painting area</dfn>,
which determines the area within which the background is painted.
The syntax of the property is given with
<pre class=prod><dfn><var><box></var></dfn> = border-box | padding-box | content-box</pre>
<p>Values have the following meanings:
<dl>
<dt><dfn title="''border-box''!!'background-clip' value">
''border-box''</dfn></dt>
<dd>The background is painted within (clipped to) the
<span>border box.</span>
<dt><dfn title="''padding-box''!!'background-clip' value">
''padding-box''</dfn></dt>
<dd>The background is painted within (clipped to) the
<span>padding box.</span>
<dt><dfn title="''content-box''!!'background-clip' value">
''content-box''</dfn></dt>
<dd>The background is painted within (clipped to) the
<span>content box.</span>
</dl>
<p class=note>Note that the root element has a different <span>background
painting area,</span> and thus the 'background-clip' property has no effect
when specified on it. See <a href="#special-backgrounds"> “The
backgrounds of special elements.”</a>
<p class=note>Note that the background is always drawn <em>behind</em>
the border, if any. See “Elaborate description of Stacking Contexts” in
[[!CSS21]].
<p>See the section on <a href="#corner-shaping">Corner Shaping</a>
for how 'border-radius' affects the shape of the <i>background painting area</i>.
<p>See the section <a href="#layering">“Layering multiple background
images”</a> for how ''background-clip'' interacts with other
comma-separated background properties to form each background image
layer.
<h3 id="the-background-origin">Positioning Area: the 'background-origin' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>background-origin</dfn>
<tr>
<th><a href="#values">Value</a>:
<td><var><box></var>
[ , <var><box></var> ]*
<tr>
<th>Initial:
<td>padding-box
<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
<tr>
<th>Animatable:
<td>no
</table>
<p>For elements rendered as a single box, specifies the
<dfn id="background-positioning-area">background positioning area</dfn>.
For elements rendered as multiple boxes
(e.g., inline boxes on several lines, boxes on several pages),
specifies which boxes 'box-decoration-break' [[CSS3-BREAK]] operates on
to determine the background positioning area(s).
<dl>
<dt><dfn title="''padding-box''!!'background-origin' value">
''padding-box''</dfn>
<dd>The position is relative to the padding box. (For single boxes
''0 0'' is the upper left corner of the padding edge,
''100% 100%'' is the lower right corner.)
<dt><dfn title="''border-box''!!'background-origin' value">
''border-box''</dfn>
<dd>The position is relative to the border box.
<dt><dfn>''content-box''</dfn>
<dd>The position is relative to the content box.
</dl>
<p>If the 'background-attachment' value for this image is
''fixed'', then this property has no effect: in this case the
background positioning area is the
<a href="http://www.w3.org/TR/CSS21/visudet.html#containing-block-details">initial containing block</a> [[!CSS21]].
<p class="note">Note that if 'background-clip' is ''padding-box'',
'background-origin' is ''border-box'', 'background-position' is
''top left'' (the initial value), and the element has a
non-zero border, then the top and left of the background image will be
clipped.
<p>See the section <a href="#layering">“Layering multiple background
images”</a> for how ''background-origin'' interacts with other
comma-separated background properties to form each background image
layer.
<h3 id="the-background-size">Sizing Images: the 'background-size' property</h3>
<table class="propdef">
<tr>
<th>Name: