-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.src.html
More file actions
1757 lines (1374 loc) · 85 KB
/
Overview.src.html
File metadata and controls
1757 lines (1374 loc) · 85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head profile="http://www.w3.org/2006/03/hcard">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CSS Image Values and Replaced Content Module Level 3</title>
<link rel="stylesheet" type="text/css" href="../default.css">
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
</head>
<div class="head">
<!--logo-->
<h1>CSS Image Values and Replaced Content Module Level 3</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This Version:</dt>
<dd><a href="[VERSION]">http://www.w3.org/TR/[YEAR]/WD-css3-images-[CDATE]/</a>
<!-- <dd><a href="http://dev.w3.org/csswg/css3-images/">http://dev.w3.org/csswg/css3-images/</a> -->
<dt>Latest Version:</dt>
<dd><a href="http://www.w3.org/TR/css3-images/">http://www.w3.org/TR/css3-images/</a></dd>
<dt>Editor's Draft:</dt>
<dd><a href="http://dev.w3.org/csswg/css3-images/">http://dev.w3.org/csswg/css3-images/</a>
<dt>Previous Version:</dt>
<dd><a href="http://www.w3.org/TR/2011/WD-css3-images-20110908/">http://www.w3.org/TR/2011/WD-css3-images-20110908/</a></dd>
<dd><a href="http://www.w3.org/TR/2011/WD-css3-images-20110712/">http://www.w3.org/TR/2011/WD-css3-images-20110712/</a></dd>
<dd><a href="http://www.w3.org/TR/2011/WD-css3-images-20110217/">http://www.w3.org/TR/2011/WD-css3-images-20110217/</a></dd>
<dd><a href="http://www.w3.org/TR/2009/WD-css3-images-20090723/">http://www.w3.org/TR/2009/WD-css3-images-20090723/</a></dd>
<dt>Editors:</dt>
<dd class='vcard'>
<a class='url fn' href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a> (<span class='org'>Mozilla</span>)</dd>
<dd class='vcard'>
<a class='url fn' href="http://www.xanthir.com/contact/">Tab Atkins Jr.</a> (<span class='org'>Google</span>)</dd>
</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 documents (such as HTML and XML) on screen, on paper, in speech, etc. This module contains the features of CSS level 3 relating to the <image> type and replaced elements. 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 the generalization of the <url> type to the <image> type, several additions to the ''<image>'' type, a generic sizing algorithm for images and other replaced content in CSS, and several properties controlling the interaction of replaced elements and CSS's layout models.</p>
<h2 class="no-num no-toc" id="status">Status of this document</h2>
<!--status-->
<p>The following features are at risk: …
<ol>
<li>The <a href="#image-notation">image() function</a></li>
<li>The <a href="#element-reference">element() function</a></li>
<li>The "none" and "scale-down" values for 'object-fit'</li>
<li>The 'image-orientation' property</li>
<li>The "snap" keyword for 'image-resolution'</li>
</ol>
<h2 class="no-num no-toc" id="contents">Table of contents</h2>
<!--toc-->
<h2 id="intro">
Introduction</h2>
<p><em>This section is not normative.</em>
<p>In CSS Levels 1 and 2, image values, such as those used in the
'background-image' property, could only be given by a single URI
value. This module introduces additional ways of representing 2D
images, for example as a list of URIs denoting fallbacks, as a
reference to an element in the document, or as a gradient.</p>
<p>This module also defines several properties for manipulating
raster images and for sizing or positioning replaced elements
such as images within the box determined by the CSS layout algorithms.
It also defines in a generic way CSS's sizing algorithm for images
and other replaced elements.
<h3 id="placement">
Module Interactions</h3>
<p>This module defines and extends the ''<image>'' value type
defined in [[!CSS3VAl]]. Furthermore it replaces the ''<url>''
type in the 'background-image' and 'list-style-image' definitions
in CSS1 and CSS2 and adds ''<image>'' as an alternative to
''<url>'' in the 'content' property's value. It is presumed that
CSS specifications beyond CSS2.1 will use the ''<image>'' notation
in place of ''<url>'' where 2D images are expected. (See e.g.
[[CSS3BG]].)
<h3 id="values">
Values</h3>
<p>This specification follows the <a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property definition conventions</a> from [[!CSS21]]. Value types not defined in this specification 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.</p>
<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.
<h2 id='resolution-units'>
Resolution Units: the <resolution> type</h2>
<p>This specification defines the following units as part of the <dfn><resolution></dfn>
value type:</p>
<dl>
<dt><dfn>dpi</dfn></dt>
<dd>dots per inch</dd>
<dt><dfn>dpcm</dfn></dt>
<dd>dots per centimeter</dd>
<dt><dfn>dppx</dfn></dt>
<dd>dots per ''px'' unit</dd>
</dl>
<p>The <resolution> unit represents the size of a single "dot" in a
graphical representation by indicating how many of these dots fit in a
CSS 'in', 'cm', or 'px'.
For uses, see e.g. the ''resolution'' media query in [[MEDIAQ]]
or the 'image-resolution' property defined below.
<p class="note">Note that due to the 1:96 fixed ratio of CSS ''in'' to
CSS ''px'', ''1dppx'' is equivalent to ''96dpi''. This corresponds to
the default resolution of images displayed in CSS: see 'image-reslution'.
<!-- ====================================================================== -->
<h2 id="image">
Image Values: the <image> type</h2>
<p>The <image> value type denotes a 2D image. It is defined as
<pre class="prod"><dfn><image></dfn> = <url> | <image-list> | <element-reference> | <gradient></pre>
<p>Image values can be used in many CSS properties, including the
'background-image', 'list-style-image', 'cursor' properties [[!CSS21]].
<!-- ====================================================================== -->
<h3 id="url">
Image References and Image Slices: the ''url()'' function</h3>
<p>The simplest way to indicate an image is to reference an image file by URL. This is done with the <a href="http://www.w3.org/TR/CSS21/syndata.html#uri">''url()'' notation</a>, defined in [[!CSS21]].
<div class="example">
<p>In the example below, a background image is specified with ''url()''
syntax:</p>
<pre>background-image: url(wavy.png);</pre>
</div>
<p>A portion of an image may be referenced (clipped out and used as a standalone image) by use of <a href="http://www.w3.org/TR/media-frags/#naming-space">media fragment identifiers</a>. [[!MEDIA-FRAGS]]
<div class="example">
<p>For example, given the following image* and CSS:</p>
<a href="sprites.svg">
<img src="sprites.svg" height="20" width="180" alt="[9 circles, with 0 to 8 eighths filled in]">
</a>
<pre>background-image: url('sprites.svg#xywh=40,0,20,20')</pre>
<p>...the background of the element will be the portion of the image that starts at (40px,0px)
and is 20px wide and tall, which is just the circle with a quarter filled in.</p>
<p><small>* SVG-in-<img> support required. Click the picture to view the SVG directly.</small></p>
</div>
<p class="note">Note that a legacy UA that doesn't understand the media
fragments notation will ignore the fragment and simply display the
entirety of an image specified with ''url''. However, since URLs with
media fragment identifiers can also be used in the ''image()'' notation
defined below, authors can take advantage of CSS's forward-compatible
parsing rules to provide a fallback when using an image fragment URL:</p>
<div class="example">
<p>In the example below, the ''image()'' notation is used together with
the media fragment syntax, so that UAs that don't support media fragments
fail to parse the second declaration and use the first.</p>
<pre>
<!-- -->background-image: url('swirl.png'); /* old UAs */
<!-- -->background-image: image('sprites.png#xywh=10,30,60,20'); /* new UAs */</pre>
</div>
<!-- ====================================================================== -->
<h3 id="image-notation">
Image Fallbacks and Annotations: the ''image()'' function</h3>
<p>The ''image()'' function allows an author to specify an image with fallback images to be used if the original image can't be decoded or is a type that the browser doesn't recognize. Additionally, the author can specify a color as an ultimate fallback to be used when none of the images can be.</p>
<p>So that authors can take advantage of CSS's forwards-compatible parsing
rules to provide a fallback for image slices, implementations that support
the ''image()'' notation <em>must</em> support the <code>xywh=#,#,#,#</code>
form of media fragment identifiers for images. [[!MEDIA-FRAGS]]
<p>The ''image()'' notation is defined as:
<pre class='prod'><dfn><image-list></dfn> =
image( [ <image-decl> , ]* [ <image-decl> | <color> ] )
<image-decl> = <string> [ ltr | rtl ]?</pre>
<p>Each <code><string></code> must represent a <a href="http://dev.w3.org/csswg/css3-values/#urls">URL</a>.</p>
<p>Multiple arguments can be given separated by commas, in which case the function represents the first <string> representing an image that the browser can successfully load and display. The final argument can specify a <color> to serve as an ultimate fallback; this can be used, e.g. for 'background-image', to ensure adequate contrast if none of the preceding <image-decl>s can be used. If the final argument is a <color>, it represents a solid-color image of the given color with no <i>intrinsic dimensions</i>.
<div class="example">
<p>The rule below would tell the UA to load ''wavy.svg'' if it can; failing that to load ''wavy.png''; failing that to display ''wavy.gif''. For example, the browser might not understand how to render SVG images, and the PNG may be temporarily 404 (returning an HTML 404 page, which the browser can't decode as an image) due to a server move, so the GIF is used until one of the previous problems corrects itself.</p>
<pre>background-image: image("wavy.svg", 'wavy.png' , "wavy.gif");</pre>
</div>
<div class='example'>
<p>The fallback color can be used to ensure that text is still readable even when the image fails to load. For example, the following code works fine if the image is rectangular and has no transparency:</p>
<pre>
body { color: black; background: white; }
p.special { color: white; background: url("dark.png") black; }</pre>
<p>When the image doesn't load, the background color is still there to ensure that the white text is readable. However, if the image has some transparency, the black will be visible behind it, which is probably not desired. The ''image()'' function addresses this:</p>
<pre>
body { color: black; background: white; }
p.special { color: white; background: image("dark.png", black); }</pre>
<p>Now, the black won't show at all if the image loads, but if for whatever reason the image fails, it'll pop in and prevent the white text from being set against a white background.</p>
</div>
<div class='example'>
<p>At times, one may need a solid-color image for a property or function that does not accept the <color> type directly. The ''image()'' function can be used for this: by specifying <em>only</em> a color without any URLs, the function immediately falls back to representing a solid-color image of the chosen color.
<pre>background-image: image(rgba(0,0,255,.5)), url("bg-image.png");</pre>
<p>In the above, the background is the image "bg-image.png", overlaid with partially-transparent blue.
</div>
<p>Along with each URL, the author may specify a directionality, similar to adding a <code>dir</code> attribute to an element in HTML. The image represented by the function takes on the directionality of the used URL. If a directional image is used on or in an element with opposite directionality, the image must be flipped in the inline direction (as if it was transformed by, e.g., <code>scaleX(-1)</code>, if the inline direction is the X axis).</p>
<div class='example'>
<p>A list may use an arrow for a bullet that points into the content. If the list can contain both ltr and rtl text, though, the bullet may be on the left or the right, and an image designed to point into the text on one side will point out of the text on the other side. This can be fixed with code like:</p>
<pre>
<ul style="list-style-image: image("arrow.png" ltr);">
<li dir='ltr'>My bullet is on the left!</li>
<li dir='rtl'>MY BULLET IS ON THE RIGHT!</li>
</ul></pre>
<p>In ltr list items, the image will be used as-is. In the rtl list items, however, it will be flipped in the inline direction, so it still points into the content.</p>
</div>
<!-- ====================================================================== -->
<h3 id='element-reference'>
Using Elements as Images: the ''element()'' function</h3>
<p>The ''element()'' function allows an author to use an element in the document as an image. As the referenced element changes appearance, the image changes as well. This can be used, for example, to create live previews of the next/previous slide in a slideshow, or to reference a canvas element for a fancy generated gradient or even an animated background. The syntax for ''element()'' is:</p>
<pre class=prod><dfn><element-reference></dfn> = element( [<id-selector> | <identifier> ] )</pre>
<p>where <id-selector> is an ID selector [[!SELECT]], and <identifier> is an identifer [[!CSS3VAL]].</p>
<p>If the argument to the ''element()'' function is an ID selector, the function references the element matched by the selector. If it's an identifier, the function references the element whose <dfn>CSS element reference identifier</dfn> is the given identifier. (CSS does not define how an element acquires a <i>CSS element reference identifier</i>; that is determined by the host language.)</p>
<div class='example'>
<p>The ''element()'' function can be put to many uses. For example, it can be used to show a preview of the previous or next slide in a slideshow:</p>
<pre>
<!DOCTYPE html>
<script>
function navigateSlides() {
var currentSlide = ...;
var prevSlide = currentSlide.previousElementSibling;
var nextSlide = currentSlide.nextElementSibling;
document.CSSElementMap['prev-slide'] = prevSlide;
document.CSSElementMap['next-slide'] = nextSlide;
}
</script>
<style>
#prev-preview, #next-preview {
position: fixed;
...
}
#prev-preview { background: element(prev-slide); }
#next-preview { background: element(next-slide); }
</style>
<div id='prev-preview'></div>
<div id='next-preview'></div>
<section class='slide'>...</section>
<section class='slide current-slide'>...</section>
...</pre>
<p>In this example, the <code>navigateSlides</code> function updates HTML's <code>CSSElementMap</code> to always point to the next and previous slides, which are then displayed in small floating boxes alongside the slides. Since you can't interact with the slides through the ''element()'' function (it's just an image), you could even use <code>click</code> handlers on the preview boxes to help navigate through the page.
<p class='note'>Note: A future version of this specification may allow more than just ID selectors to be passed to ''element()'', allowing an example like this to be done with even less javascript - something like ''background: element(.current-slide + .slide);''.</p>
</div>
<p>The image represented by the ''element()'' function can vary based on a number of factors. The function must represent the image described by the first set of conditions, following, that are true:</p>
<dl>
<dt>The function doesn't reference an element</dt>
<dd>The function represents a solid-color transparent-black image with no intrinsic dimensions.</dd>
<dt>The function references an element that is not rendered, but which <i title=paint-source>provides a paint source</i></dt>
<dd>
<p>The function represents an image with the dimensions and appearance of the <i title=paint-source>paint source</i>. The host language defines the dimensions and appearance of paint sources.
<div class='example'>
<p>For example, the ''element()'' function can reference an SVG <pattern> element in an HTML document:</p>
<pre>
<!DOCTYPE html>
<svg>
<defs>
<pattern id='pattern1'>
<path d='...'>
</pattern>
</defs>
</svg>
<p style="background: element(#pattern1)">
I'm using the pattern as a background!
If the pattern is changed or animated,
my background will be updated too!
</p></pre>
<p>HTML also defines that a handful of elements, such as <canvas>, <img>, and <video>, provide a paint source. This means that CSS can, for example, reference a canvas that's being drawn into, but not included in the page:</p>
<pre>
<!DOCTYPE html>
<script>
var canvas = document.createElement('canvas');
canvas.width = 20; canvas.height = 20;
document.CSSElementMap.foo = canvas;
drawAnimation(canvas);
</script>
<ul style="list-style-image: element(foo);">
<li>I'm using the canvas as a bullet!</li>
<li>So am I!</li>
<li>As the canvas is changed over time with Javascript,
we'll all update our bullet image with it!</li>
</ul></pre>
</div>
</dd>
<dt>The function references an element that is not rendered</dt>
<dt>The function references an element that is a descendant of a replaced element</dt>
<dd>
<p>The function represents a solid-color transparent-black image with no intrinsic dimensions.</p>
<div class='example'>
<p>For example, all of the following ''element()'' uses will result in a transparent background:</p>
<pre>
<!DOCTYPE html>
<script>
var p = document.createElement('p');
p.textContent = "one";
document.CSSElementMap.one = p;
</script>
<p id='two' style="display:none;">two</p>
<iframe src="http://example.com">
<p id='three'>I'm fallback content!</p>
</iframe>
<ul>
<li style="background: element(one);">
A P element doesn't provide a paint source,
and it's not rendered unless it's in a document.
</li>
<li style="background: element(#two);">
Similarly, a display:none element isn't rendered, and
P still doesn't provide a paint source.
</li>
<li style="background: element(#three);">
The descendants of a replaced element like an IFRAME
can't be used in element() either.
</li>
</ul></pre>
</div>
</dd>
<dt>Otherwise</dt>
<dd>
<p>The function represents an image with width and height equal to the bounding box of the referenced element. The image must be constructed by rendering the referenced element and its descendants at the same size that the element would be in its document, over an infinite transparent-black canvas, positioned so that the edges of the referenced element's bounding box is flush with the edges of the image. <span class=note>Note: Because images clip anything outside their bounds by default, this means that decorations that extend outside the bounding box, like box-shadows or some border-images, may be clipped.</span></p>
<p>If the referenced element has a transform applied to it or an ancestor, the transform must be ignored when rendering the element as an image. If the referenced element is broken across pages, the element must be displayed as if the page content areas were joined flush in the pagination direction (elements broken across lines or columns just render with their bounding box, as normal, which may have unintended visual effects).</p>
<div class='example'>
<p>As a somewhat silly example, a <p> element can be reused as a background elsewhere in the document:</p>
<pre>
<style>
#src { color: white; background: lime; width: 300px; height: 40px; }
#dst { color: black; background: element(#src); padding: 20px; margin: 20px 0; }
</style>
<p id='src'>I'm an ordinary element!</p>
<p id='dst'>I'm using the previous element as my background!</p></pre>
<img src="element-function.png" alt="">
</div>
</dd>
</dl>
<p>Implementations may either re-use existing bitmap data generated for the
referenced element or regenerate the display of the element to maximize quality
at the image's size (for example, if the implementation detects that the referenced
element is an SVG fragment); in the latter case, the layout of the referenced
element in the image must not be changed by the regeneration process. That is,
the image must look identical to the referenced element, modulo rasterization
quality.</p>
<p>Host languages may define that some elements provide a <dfn title="paint-source">paint source</dfn>. Paint sources have an intrinsic width, height, and appearance, separate from the process of rendering, and so may be used as images even when they're not being rendered. Examples of elements that provide paint sources are the <linearGradient>, <radialGradient>, and <pattern> elements in SVG, or the <img>, <video>, and <canvas> elements in HTML.</p>
<!-- ====================================================================== -->
<h4 class="no-num no-toc" id='element-cycles'>
Detecting and Resolving Circular Relationships Introduced by ''element()''</h4>
<p>The ''element()'' function can produce nonsensical circular relationships,
such as an element using itself as its own background. These relationships
can be easily and reliably detected and resolved, however, by keeping
track of a dependency graph and using common cycle-detection algorithms.</p>
<p>Populate the dependency graph initially by having every element depend
on each of its children. Then, whenever a property on an element A uses
the ''element()'' function to refer to an element B, add an edge to the
graph by having A depend on B. If a dependency cycle is detected, any
''element()'' functions that produced a dependency in the cycle must represent
a fully transparent image with no intrinsic dimensions.</p>
<p class=issue>Someone else needs to review this and make sure that I'm
not missing any cycles.</p>
<h2 id="gradients">
Gradients</h2>
<p>A gradient is an image that smoothly fades from one color to another. These
are commonly used for subtle shading in background images, buttons, and many
other things. The two functions described in this section allow an author to
specify such an image in a terse syntax, so that the UA can generate the image
automatically when rendering the page.
The syntax of a <i><gradient></i> is:</p>
<pre class=prod><dfn><gradient></dfn> = [ <linear-gradient> | <radial-gradient> | <repeating-linear-gradient> | <repeating-radial-gradient> ]</pre>
<p>where <i><linear-gradient></i>, <i><radial-gradient></i>,
<i><repeating-linear-gradient></i>, and <i><repeating-radial-gradient></i> are
defined in their applicable sections below.</p>
<p>Gradients are a type of image, and can be used anywhere an image can,
such as in the 'background-image' or 'list-style-image' properties.
<div class=example>
<p>As with the other <i><image></i> types defined in this specification,
gradients can be used in any property that accepts images. For example:</p>
<ul>
<li><code>background: linear-gradient(white, gray);</code></li>
<li><code>list-style-image: radial-gradient(circle, #006, #00a 90%, #0000af 100%, white 100%)</code></li>
</ul>
</div>
<p>A gradient is drawn into a box with the dimensions of the <i>concrete
object size</i>, referred to as the <dfn>gradient box</dfn>.</p>
<p>A gradient has no <i>intrinsic dimensions</i>. This means that, for
example, if you use a gradient in the 'background-image' property (with
'background-size' at the default value and 'background-repeat' not equal to
'round'), the box will simply be the size of the background sizing
area. Similarly, for a gradient used as a list-style-image, the box
would be a 1em square.
<!-- ====================================================================== -->
<h3 id='linear-gradients'>
Linear Gradients</h3>
<p>A linear gradient is created by specifying a gradient-line and then several
colors placed along that line. The image is constructed by creating an
infinite canvas and painting it with lines perpendicular to the gradient-line,
with the color of the painted line being the color of the gradient-line
where the two intersect. This produces a smooth fade from each color to
the next, progressing in the specified direction.</p>
<!-- ====================================================================== -->
<h4 class='no-toc' id='linear-gradient-syntax'>
linear-gradient() syntax</h4>
<pre class=prod><code>
<dfn><linear-gradient></dfn> = linear-gradient(
[ [ <angle> | to <side-or-corner> ] ,]?
<color-stop>[, <color-stop>]+
)
<dfn id='side-or-corner'><side-or-corner></dfn> = [left | right] || [top | bottom]</code></pre>
<p>The first argument to the function specifies the <dfn>gradient-line</dfn>,
which gives the gradient a direction and determines how color-stops are
positioned. It may be omitted; if so, it defaults to "to bottom".</p>
<p>The <i>gradient-line</i> may be specified in two different ways. The
first is by specifying the angle the <i>gradient-line</i> should assume;
for the purposes of this argument, 0deg points upwards, 90deg points toward
the right, and positive angles go clockwise.
The starting-point and ending-point of the <i>gradient-line</i> are
determined by extending a line in both directions from the center of the
<i>gradient box</i> at the angle specified. In the direction of the angle, the ending-point
is the point on the <i>gradient-line</i> where a line drawn perpendicular
to the <i>gradient-line</i> would intersect the corner of the <i>gradient box</i> in that
direction. The starting-point is determined identically, except in the
opposite direction of the angle.</p>
<p>Alternately, the direction may be specified with keywords that denote the direction. If the argument is "to top", "to right", "to bottom", or "to left", the gradient must be rendered identically to "0deg", "90deg", "180deg", or "270deg", respectively. If the argument specifies a corner to angle towards, the gradient must be rendered identically to an angle-based gradient with an angle chosen such that the endpoint of the gradient is in the same quadrant as the indicated corner, and a line drawn perpendicular to the gradient-line through the center of the <i>gradient box</i> intersects the two neighboring corners.</p>
<p class='note'>It is expected that the next level of this module will provide the ability to define the gradient's direction relative to the current text direction and writing-mode.</p>
<p>
<div class=example>
<div style="overflow: hidden">
<img style="float: right; margin-left: 1em;" src='gradient-diagram.png' alt="[An image showing a box with a background shading gradually from white in the bottom-left corner to black in the top-right corner. There is a line, illustrating the gradient-line, angled at 45 degrees and passing through the center of the box. The starting-point and ending-point of the gradient-line are indicated by the intersection of the gradient-line with two additional lines that pass through the bottom-left and top-right corners of the box.]">
<p>This example illustrates visually how to calculate the
<i>gradient-line</i> from the rules above. This shows the starting
and ending-point of the <i>gradient-line</i>, along with the actual
gradient, produced by an element with
''background: linear-gradient(45deg, white, black);''.</p>
<p>Notice how, though the starting-point and ending-point are outside
of the box, they're positioned precisely right so that the gradient
is pure white <em>exactly</em> at the corner, and pure black
<em>exactly</em> at the opposite corner. That's intentional, and
will always be true for linear gradients.</p>
</div>
</div>
<p>The gradient's color stops are typically placed between the starting-point
and ending-point on the <i>gradient-line</i>, but this isn't required - the
<i>gradient-line</i> extends infinitely in both directions. The starting-point
and ending-point are merely arbitrary location markers - the starting-point
defines where 0%, 0px, etc are located when specifying color-stops, and
the ending-point defines where 100% is located. Color-stops are allowed
to have positions before 0% or after 100%.</p>
<!-- ====================================================================== -->
<h4 class='no-toc' id='linear-gradient-examples'>
Linear Gradient Examples</h4>
<p>All of the following ''linear-gradient()'' examples are presumed to be
backgrounds applied to a box that is 200px wide and 100px tall.</p>
<div class=example>
<p>Below are various ways of specifying a basic vertical gradient:</p>
<pre><code>linear-gradient(yellow, blue);
linear-gradient(to bottom, yellow, blue);
linear-gradient(180deg, yellow, blue);
linear-gradient(to top, blue, yellow);
linear-gradient(to bottom, yellow 0%, blue 100%);</code></pre>
<p><img src="linear1.png" alt="" ></p>
</div>
<div class=example>
<p>This demonstrates the use of an angle in the gradient. Note that, though the angle is not exactly the same as the angle between the corners, the <i>gradient-line</i> is still sized so as to make the gradient yellow exactly at the upper-left corner, and blue exactly at the lower-right corner.</p>
<pre><code>linear-gradient(135deg, yellow, blue);
linear-gradient(-45deg, blue, yellow);</code></pre>
<p><img src="linear3.png" alt="" ></p>
</div>
<div class=example>
<p>This demonstrates a 3-color gradient, and how to specify the location of a stop explicitly:</p>
<pre><code>linear-gradient(yellow, blue 20%, #0f0);</code></pre>
<p><img src="linear4.png" alt="" ></p>
</div>
<div class=example>
<p>This demonstrates* a corner-to-corner gradient specified with keywords. Note how the gradient is red and blue exactly in the bottom-left and top-right corners, respectively, exactly like the second example. Additionally, the angle of the gradient is automatically computed so that the color at 50% (in this case, white) stretches across the top-left and bottom-right corners.</p>
<pre><code>linear-gradient(to top right, red, white, blue)</code></pre>
<p><object data="gradient1.svg" width="200"
height="100">(Image requires SVG)</object></p>
<p><small>* SVG-in-HTML support required to view the image.</small></p>
</div>
<!-- ====================================================================== -->
<h3 id='radial-gradients'>
Radial Gradients</h3>
<p>In a radial gradient, rather than colors smoothly fading from one side
of the <i>gradient box</i> to the other as with linear gradients, they instead emerge from
a single point and smoothly spread outward in a circular or elliptical shape.</p>
<p>A radial gradient is specified by indicating the center
of the gradient (where the 0% ellipse will be) and the size
and shape of the <dfn>ending shape</dfn> (the 100% ellipse). Color stops
are given as a list, just as for ''linear-gradient()''.
Starting from the <i>center</i> and progressing towards (and potentially
beyond) the <i>ending shape</i> concentric ellipses are drawn and colored
according to the specified color stops.</p>
<!-- ====================================================================== -->
<h4 class='no-toc' id='radial-gradient-syntax'>
radial-gradient() Syntax</h4>
<p>The radial gradient syntax is defined as follows:
<pre>
<radial-gradient> = radial-gradient(
[ [ <shape> || <size> ] [ at <position> ]? , |
at <position>,
]?
<color-stop> [ , <color-stop> ]+
)</pre>
<div class=example>
<p>Here is an example of a circular radial gradient 5em wide and
positioned with its center in the top left corner:
<pre>radial-gradient(5em circle at top left, yellow, blue)</pre>
</div>
<p>The arguments are defined as follows:
<dl>
<dt id='radial-position'><dfn><position></dfn></dt>
<dd>Determines the center of the gradient. The <i><position></i> notation
is defined as the positioning syntax of a single layer of
'<a href="http://www.w3.org/TR/css3-background/#the-background-position">background-position</a>'
and is resolved in the same way, using the center-point as the subject and
the <i>gradient box</i> as the positioning area. [[!CSS21]] [[!CSS3BG]]
If this argument is omitted, it defaults to ''center''.
<dt id='radial-shape'><dfn><shape></dfn></dt>
<dd>Can be either ''circle'' or ''ellipse''; determines whether the
gradient's <i>ending shape</i> is a circle or an ellipse, respectively.
If <i><shape></i> is omitted, the <i>ending shape</i> defaults
to a circle if the <i><size></i> is a single <length>,
and to an ellipse otherwise.
<dt id='radial-size'><dfn><size></dfn>
<dd>
<p>Determines the size of the gradient's <i>ending shape</i>. If
omitted it defaults to ''farthest-corner''. It can be given explicitly or
by keyword. For the purpose of the keyword definitions, consider the
<i>gradient box</i> edges as extending infinitely in both directions, rather than
being finite line segments.
<p>Both ''circle'' and ''ellipse'' gradients accept the following keywords
as their <i><size></i>:
<dl>
<dt><dfn id='radial-closest-side'>''closest-side''</dfn></dt>
<dd>The <i>ending shape</i> is sized so that that it exactly meets the
side of the <i>gradient box</i> closest to the gradient's center. If the shape is an
ellipse, it exactly meets the closest side in each dimension.</dd>
<dt><dfn id='radial-farthest-side'>''farthest-side''</dfn></dt>
<dd>Same as ''closest-side'', except the <i>ending shape</i> is sized
based on the farthest side(s).</dd>
<dt><dfn id='radial-closest-corner'>''closest-corner''</dfn></dt>
<dd>The <i>ending shape</i> is sized so that that it passes through the
corner of the <i>gradient box</i> closest to the gradient's center. If the shape is an
ellipse, the <i>ending shape</i> is given the same aspect-ratio
it would have if ''closest-side'' were specified.
<dt><dfn id='radial-farthest-corner'>''farthest-corner''</dfn></dt>
<dd>Same as ''closest-corner'', except the <i>ending shape</i> is
sized based on the farthest corner. If the shape is an ellipse,
the <i>ending shape</i> is given the same aspect ratio it would
have if ''farthest-side'' were specified.
</dl>
<p>If <i><shape></i> is specified as ''circle'' or is omitted, the
<i><size></i> may be given explicitly as:
<dl>
<dt><dfn id='radial-size-circle'><length></dfn></dt>
<dd>
<p>Gives the radius of the circle explicitly. Negative values are
invalid.</p>
<p class='note'>Note that percentages are <em>not</em> allowed here; they can only be used to specify the size of an elliptical gradient, not a circular one. This restriction exists because there is are multiple reasonable answers as to which dimension the percentage should be relative to. A future level of this module may provide the ability to size circles with percentages, perhaps with more explicit controls over which dimension is used.</p>
</dd>
</dl>
<p>If <i><shape></i> is specified as ''ellipse'' or is omitted,
<i><extent></i> may instead be given explicitly as:
<dl>
<dt><dfn id='radial-size-ellipse'>[<length> | <percentage>]{2}</dfn></dt>
<dd>Gives the size of the ellipse explicitly. The first value represents
the horizontal radius, the second the vertical radius. Percentages
values are relative to the corresponding dimension of the <i>gradient box</i>.
Negative values are invalid.
</dl>
</dd>
</dl>
<div class='note'>
<p>Expanded with the above definitions, the grammar becomes:
<pre>
<radial-gradient> = radial-gradient(
[ [ circle || <length> ] [ at <position> ]? , |
[ ellipse || [ <length> | <percentage> ]{2} ] [ at <position> ]? , |
[ [ circle | ellipse ] || <extent-keyword> ] [ at <position> ]? , |
at <position> ,
]?
<color-stop> [ , <color-stop> ]+
)
<extent-keyword> = closest-corner | closest-side | farthest-corner | farthest-side</pre>
</div>
<h4 class="no-toc" id="radial-color-stops">
Placing Color Stops</h4>
<p>Color-stops are placed on a <dfn>gradient-ray</dfn>, similar to the <i>gradient-line</i> of linear gradients. The <i>gradient-ray</i> is anchored at the center of the gradient and extends toward the right. The 0% location is at the start of the <i>gradient-ray</i>, and the 100% location is on the point where the <i>gradient-ray</i> intersects the <i>ending shape</i>. Negative locations can be specified; though negative locations are never directly consulted for rendering, they can affect the color of non-negative locations on the <i>gradient-ray</i> through interpolation. For example, ''radial-gradient(red -50px, yellow 100px)'' produces an elliptical gradient that starts with a reddish-orange color in the center (specifically, #f50) and transitions to yellow. Locations greater than 100% simply specify a location a correspondingly greater distance from the center of the gradient.</p>
<p>When drawing the concentric ellipses of the gradient, the color of each ellipse is the color of the <i>gradient-ray</i> at the point where the ellipse intersects the ray.</p>
<h4 class="no-toc" id="degenerate-radials">
Degenerate Radial Gradients</h4>
<p>Some combinations of position, size, and shape will produce a circle
or ellipse with a radius of 0. This will occur, for example, if the
center is on a <i>gradient box</i> edge and ''closest-side'' or ''closest-corner'' is
specified or if the size and shape are given explicitly and either of
the radiuses is zero. In these degenerate cases, the gradient must be
be rendered as follows:</p>
<dl>
<dt>If the <i>ending shape</i> has zero width (regardless of the height):</dt>
<dd>Render as if the <i>ending shape</i> was an ellipse whose height was an arbitrary very large number and whose width was an arbitrary very small number greater than zero. <span class='note'>This will make the gradient look similar to a horizontal linear gradient that is mirrored across the center of the ellipse. It also means that all color-stop positions specified with a percentage resolve to ''0px''.</span></dd>
<dt>Otherwise, if the <i>ending shape</i> has zero height:</dt>
<dd>Render as if the <i>ending shape</i> was an ellipse whose width was an arbitrary very large number and whose height was an arbitrary very small number greater than zero. <span class='note'>This will make the gradient look like a solid-color image equal to the color of the last color-stop, or equal to the average color of the gradient if it's repeating.</span></dd>
</dl>
<!-- ====================================================================== -->
<h4 class='no-toc' id='radial-gradient-examples'>
Radial Gradient Examples</h4>
<p>All of the following examples are applied to a box that is 200px wide
and 100px tall.</p>
<div class=example>
<p>These examples demonstrate different ways to write the basic syntax for radial gradients:</p>
<pre><code>radial-gradient(yellow, green);
radial-gradient(ellipse at center, yellow 0%, green 100%);
radial-gradient(farthest-corner at 50% 50%, yellow, green);</code></pre>
<p><img src="radial1.png" alt="" ></p>
<pre><code>radial-gradient(circle, yellow, green);</code></pre>
<p><img src="radial2.png" alt="" ></p>
<pre><code>radial-gradient(red, yellow, green);</code></pre>
<p><img src="radial3.png" alt="" ></p>
</div>
<div class=example>
<p>This image shows a gradient originating from somewhere other than the center of the box:</p>
<pre><code>radial-gradient(farthest-side at left bottom, red, yellow 50px, green);</code></pre>
<p><img src="radial4.png" alt="" ></p>
</div>
<div class=example>
<p>Here we illustrate a 'closest-side' gradient.</p>
<pre><code>radial-gradient(closest-side at 20px 30px, red, yellow, green);
radial-gradient(20px 30px at 20px 30px, red, yellow, green);</code></pre>
<p><img src="radial6.png" alt="" ></p>
<pre><code>radial-gradient(closest-side circle at 20px 30px, red, yellow, green);
radial-gradient(20px 20px at 20px 30px, red, yellow, green);</code></pre>
<p><img src="radial7.png" alt="" ></p>
</div>
<!-- ====================================================================== -->
<h3 id='repeating-gradients'>
Repeating Gradients</h3>
<p>In addition to the ''linear-gradient()'' and ''radial-gradient()'' functions,
this specification defines ''repeating-linear-gradient()'' and
''repeating-radial-gradient()'' functions. These two functions take the
same values and are interpreted the same as their respective non-repeating
siblings defined previously.</p>
<p>When rendered, however, the color-stops are repeated infinitely in both
directions, with their positions shifted by multiples of the difference
between the last specified color-stop's position and the first specified
color-stop's position. For example, ''repeating-linear-gradient(red 10px, blue 50px)''
is equivalent to ''linear-gradient(..., red -30px, blue 10px, red 10px, blue 50px, red 50px, blue 90px, ...)''.
Note that the last color-stop and first color-stop will always coincide at
the boundaries of each group, which will produce sharp transitions if the
gradient does not start and end with the same color.</p>
<div class=example>
<p>Repeating gradient syntax is basically identical to that of non-repeating gradients:</p>
<pre><code>repeating-linear-gradient(red, blue 20px, red 40px)</code></pre>
<p><img src="repeating1.png" alt=""></p>
<pre><code>repeating-radial-gradient(red, blue 20px, red 40px)</code></pre>
<p><img src="repeating2.png" alt=""></p>
<pre><code>repeating-radial-gradient(circle closest-side at 20px 30px, red, yellow, green 100%, yellow 150%, red 200%)</code></pre>
<p><img src="repeating3.png" alt=""></p>
</div>
<p>If the distance between the first and last color-stops is non-zero, but is small enough that the implementation knows that the physical resolution of the output device is insufficient to faithfully render the gradient, the implementation must <i title="gradient-average-color">find the average color of the gradient</i> and render the gradient as a solid-color image equal to the average color.</p>
<p>If the distance between the first and last color-stops is zero (or rounds to zero due to implementation limitations), the implementation must <i title="gradient-average-color">find the average color</i> of a gradient with the same number and color of color-stops, but with the first and last color-stop an arbitrary non-zero distance apart, and the remaining color-stops equally spaced between them. Then it must render the gradient as a solid-color image equal to that average color.</p>
<p>If the height of a repeating radial gradient is zero, or is close enough to zero that the implementation knows that the physical resolution of the output device is insufficient to faithfully render the gradient, the implementation must <i title="gradient-average-color">find the average color of the gradient</i> and render the gradient as a solid-color image equal to the average color.</p>
<p>To <dfn title="gradient-average-color">find the average color of a gradient</dfn>, run these steps:</p>
<ol>
<li>Define <var>list</var> as an initially-empty list of premultiplied RGBA colors, and <var>total-length</var> as the distance between first and last color stops.</li>
<li>For each adjacent pair of color-stops, define <var>weight</var> as half the distance between the two color-stops, divided by <var>total-length</var>. Add two entries to <var>list</var>, the first obtained by representing the color of the first color-stop in premultiplied sRGBA and scaling all of the components by <var>weight</var>, and the second obtained in the same way with the second color-stop.</li>
<li>Sum the entries of <var>list</var> component-wise to produce the average color, and return it.</li>
</ol>
<p class='note'>As usual, implementations may use whatever algorithm they wish, so long as it produces the same result as the above.</p>
<div class='example'>
<p>For example, the following gradient is rendered as a solid light-purple image (equal to <code>rgb(75%,50%,75%)</code>):</p>
<pre class="css">repeating-linear-gradient(red 0px, white 0px, blue 0px);</pre>
<p>The following gradient would render the same as the previous under normal circumstances (because desktop monitors can't faithfully render color-stops 1/10th of a pixel apart), but would render as a normal repeating gradient if, for example, the author applied "zoom:100;" to the element on which the gradient appears:</p>
<pre class="css">repeating-linear-gradient(red 0px, white .1px, blue .2px);</pre>
</div>
<!-- ====================================================================== -->
<h3 id='color-stop-syntax'>
Gradient Color-Stops</h3>
<pre class=prod><code><dfn><color-stop></dfn> = <color> [ <percentage> | <length> ]?</code></pre>
<p>Color-stops are points placed along the line defined by the <i>gradient-line</i>
at the beginning of the rule. Color-stops must be specified in order.
Percentages refer to the length of the gradient-line, with 0% being at the
starting point and 100% being at the ending point. Lengths are measured
from the starting-point in the direction of the ending-point. Color-stops
are usually placed between the starting-point and ending-point, but that's
not required; the gradient-line extends infinitely in both directions, and
a color-stop can be placed at any position on the line.</p>
<p>At each color-stop, the line is the color of the color-stop. Between
two color-stops, the line's color is linearly interpolated between the colors
of the two color-stops, with the interpolation taking place in premultiplied
RGBA space. Before the first color-stop, the line is the color of the first
color-stop. After the last color-stop, the line is the color of the last
color-stop.</p>
<p>The following steps must be applied <em>in order</em> to process the list
of color-stops. After applying these rules, all color-stops will have a
definite position and they will be in ascending order:</p>
<ol>
<li>If the first color-stop does not have a position, set its position to 0%. If the last color-stop does not have a position, set its position to 100%.</li>
<li>If a color-stop has a position that is less than the specified position of any color-stop before it in the list, set its position to be equal to the largest specified position of any color-stop before it.</li>
<li>If any color-stop still does not have a position, then, for each run of adjacent color-stops without positions, set their positions so that they are evenly spaced between the preceding and following color-stops with positions.</li>
</ol>
<p>If multiple color-stops have the same position, they produce an infinitesimal
transition from the one specified first in the rule to the one specified
last. In effect, the color suddenly changes at that position rather than
smoothly transitioning.</p>
<div class=example>
<p>Below are several pairs of gradients. The latter of each pair is a manually "fixed-up" version of the former, obtained by applying the above rules. For each pair, both gradients will render identically. <span class='note'>The numbers in each arrow specify which fixup steps are invoked in the transformation.</span></p>
<pre><code>
1. linear-gradient(red, white 20%, blue)
=1=>
linear-gradient(red 0%, white 20%, blue 100%)
2. linear-gradient(red 40%, white, black, blue)
=13=>
linear-gradient(red 40%, white 60%, black 80%, blue 100%)
3. linear-gradient(red -50%, white, blue)
=13=>
linear-gradient(red -50%, white 25%, blue 100%)
4. linear-gradient(red -50px, white, blue)
=13=>
linear-gradient(red -50px, white calc(-25px + 50%), blue 100%)
5. linear-gradient(red 20px, white 0px, blue 40px)
=2=>
linear-gradient(red 20px, white 20px, blue 40px)
6. linear-gradient(red, white -50%, black 150%, blue)
=12=>
linear-gradient(red 0%, white 0%, black 150%, blue 150%)
7. linear-gradient(red 80px, white 0px, black, blue 100px)
=23=>
linear-gradient(red 80px, white 80px, black 90px, blue 100px)</code></pre>
</div>
<div class=example>
<p>The following example illustrates* the difference between a gradient transitioning in pre-multiplied sRGBA and one transitioning (incorrectly) in non-premultiplied. In both of these example, the gradient is drawn over a white background. Both gradients could be written with the following value:</p>
<pre><code>linear-gradient(90deg, red, transparent, blue)</code></pre>
<p>In premultiplied space, transitions to or from "transparent" always look nice:</p>
<p><object data="gradient2.svg" width="200"
height="100">(Image requires SVG)</object></p>
<p>On the other hand, if a gradient were to incorrectly transition in non-premultiplied space, the colors near "transparent" would noticeably darken to a grayish color, because "transparent" is actually a shorthand for ''rgba(0,0,0,0)'', or transparent black:</p>
<p><object data="gradient3.svg" width="200"
height="100">(Image requires SVG)</object></p>
<p><small>* SVG-in-HTML support required to view the images.</small></p>
</div>
<p class=note>Note: It is recommended that authors not mix different types of units, such as px, em, or %, in a single rule, as this can cause a color-stop to unintentionally try to move before an earlier one. For example, the rule ''background-image: linear-gradient(yellow 100px, blue 50%)'' wouldn't require any fix-up as long as the background area is at least 200px tall. If it was 150px tall, however, the blue color-stop's position would be equivalent to "75px", which precedes the yellow color-stop, and would be corrected to a position of 100px.</p>
<p class=note>Note: The definition and implications of "premultiplied" color spaces
are given elsewhere in the technical literature, but a quick primer is given
here to illuminate the process. Given a color expressed as an rgba() 4-tuple,
one can convert this to a premultiplied representation by multiplying the
red, green, and blue components by the alpha component. For example, a
partially-transparent blue may be given as rgba(0,0,255,.5), which would
then be expressed as [0, 0, 127.5, .5] in its premultiplied representation.
Interpolating colors using the premultiplied representations rather than
the plain rgba representations tends to produce more attractive transitions,
particularly when transitioning from a fully opaque color to fully transparent.
Note that transitions where either the transparency or the color are held constant (for example, transitioning between rgba(255,0,0,100%) and rgba(0,0,255,100%) or rgba(255,0,0,100%) and rgba(255,0,0,0%)) have identical results whether the color interpolation is done in premultiplied or non-premultiplied color-space. Differences only arise when both the color and transparency differ between the two endpoints.</p>
<!-- ====================================================================== -->
<h2 id="sizing">
Sizing Images and Objects in CSS</h2>
<p>Images used in CSS may come from a number of sources, from binary image
formats (such as gif, jpeg, etc), dedicated markup formats (such as SVG), and
CSS-specific formats (such as the linear-gradient() value type defined in this
specification). As well, a document may contain many other types of objects,
such as video, plugins, or nested documents. These images and objects (just
<dfn>objects</dfn> hereafter) may offer many types of sizing information to CSS, or none
at all. This section defines generically the size negotiation model between
the object and the CSS layout algorithms.</p>
<!-- ====================================================================== -->
<h3 id="sizing-terms">
Object-Sizing Terminology</h3>
<p>In order to define this handling, we define a few terms, to make it
easier to refer to various concepts:</p>
<dl>
<dt><dfn>intrinsic dimensions</dfn></dt>
<dd>
<p>An object's intrinsic dimensions are its preferred, natural width,
height, and aspect ratio, if they exist. There can be an <dfn>intrinsic height</dfn>
and <dfn>intrinsic width</dfn>, defining a definite rectangle and an
<i>intrinsic aspect ratio</i>. (Most bitmap images fall into this category.)
There can be only an <dfn>intrinsic aspect ratio</dfn> defining the
relation of the width to the height, but no definite size.
(SVG images designed to scale may fall into this category.) There can be
just an intrinsic height or width. Or there can be no intrinsic dimensions
at all, implying that the object has no preferred size or aspect ratio.
(Embedded documents are often assumed to have no intrinsic size, as are
CSS gradients, defined in this specification.)</p>