-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.html
More file actions
1212 lines (978 loc) · 83.3 KB
/
Overview.html
File metadata and controls
1212 lines (978 loc) · 83.3 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
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>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Image Values and Replaced Content Module Level 4</title>
<link href=../default.css rel=stylesheet type=text/css>
<link href=../csslogo.ico rel="shortcut icon" type=image/x-icon>
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
<style>svg.railroad-diagram{background-color:hsl(30,20%,95%);}svg.railroad-diagram path{stroke-width:3;stroke:black;fill:rgba(0,0,0,0);}svg.railroad-diagram text{font:bold 14px monospace;text-anchor:middle;}svg.railroad-diagram text.label{text-anchor:start;}svg.railroad-diagram text.comment{font:italic 12px monospace;}svg.railroad-diagram rect{stroke-width:3;stroke:black;fill:hsl(120,100%,90%);}</style></head>
<body class=h-entry>
<div class=head>
<p data-fill-with=logo><a class=logo href=http://www.w3.org/>
<img alt=W3C height=48 src=https://www.w3.org/Icons/w3c_home width=72>
</a>
</p>
<h1 class="p-name no-ref" id=title>CSS Image Values and Replaced Content Module Level 4</h1>
<h2 class="no-num no-toc no-ref heading settled" id=subtitle><span class=content>Editor’s Draft,
<span class=dt-updated><span class=value-title title=20141003>3 October 2014</span></span></span></h2>
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-images-4/>http://dev.w3.org/csswg/css-images-4/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css4-images/>http://www.w3.org/TR/css4-images/</a><dt>Previous Versions:<dd><a href=http://www.w3.org/TR/2012/WD-css4-images-20120911/ rel=previous>http://www.w3.org/TR/2012/WD-css4-images-20120911/</a><dt>Feedback:<dd><span><a href="mailto:www-style@w3.org?subject=[css-images] feedback">www-style@w3.org</a> with subject line “<kbd>[css-images] <var>… message topic …</var></kbd>” (<a href=http://lists.w3.org/Archives/Public/www-style/ rel=discussion>archives</a>)</span><dt>Editors:<dd><div class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://xanthir.com/contact/>Tab Atkins Jr.</a> (<span class="p-org org">Google</span>)</div><dd><div class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://fantasai.inkedblade.net/contact>fantasai</a> (<span class="p-org org">Mozilla</span>)</div><dt>Issue Tracking:<dd><span><a href=http://www.w3.org/Style/CSS/Tracker/products/27>http://www.w3.org/Style/CSS/Tracker/products/27</a></span></dl></div>
<div data-fill-with=warning></div>
<p class=copyright data-fill-with=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> © 2014 <a href=http://www.w3.org/><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href=http://www.csail.mit.edu/><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href=http://www.ercim.eu/><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href=http://www.keio.ac.jp/>Keio</a>, <a href=http://ev.buaa.edu.cn/>Beihang</a>), All Rights Reserved. W3C <a href=http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer>liability</a>, <a href=http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks>trademark</a> and <a href=http://www.w3.org/Consortium/Legal/copyright-documents>document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id=abstract><span class=content>Abstract</span></h2>
<div class=p-summary data-fill-with=abstract><p>This is a delta spec over Images 3; when next published, it will be a real spec with everything filled in, but for now removing duplication is more important than having a complete spec.</p>
<a href=http://www.w3.org/TR/CSS/>CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.</div>
<h2 class="no-num no-toc no-ref heading settled" id=status><span class=content>Status of this document</span></h2>
<div data-fill-with=status><p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
<p>
The (<a href=http://lists.w3.org/Archives/Public/www-style/>archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-images%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>
(see <a href=http://www.w3.org/Mail/Request>instructions</a>)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “css-images” in the subject,
preferably like this:
“[css-images] <em>…summary of comment…</em>”
<p>
This document was produced by the <a href=http://www.w3.org/Style/CSS/members>CSS Working Group</a>
(part of the <a href=http://www.w3.org/Style/>Style Activity</a>).
<p>
This document was produced by a group operating under
the <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/>5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href=http://www.w3.org/2004/01/pp-impl/32061/status rel=disclosure>public list of any patent disclosures</a>
made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential>Essential Claim(s)</a>
must disclose the information in accordance with <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure>section 6 of the W3C Patent Policy</a>.</div>
<div data-fill-with=at-risk></div>
<h2 class="no-num no-toc no-ref heading settled" id=contents><span class=content>Table of Contents</span></h2>
<div data-fill-with=table-of-contents><ul class=toc><li><a href=#image-values><span class=secno>1</span> <span class=content>Images Values: the <span class=production data-link-type=type title="<image>"><image></span> type</span></a><ul class=toc><li><a href=#image-notation><span class=secno>1.1</span> <span class=content>Image Fallbacks and Annotations: the <span class=css data-link-type=maybe title=image()>image()</span> notation</span></a><ul class=toc><li><a href=#bidi-images><span class=secno>1.1.1</span> <span class=content>Bidi-sensitive Images</span></a></ul><li><a href=#element-notation><span class=secno>1.2</span> <span class=content>
Using Elements as Images: the <span class=css data-link-type=maybe title=element()>element()</span> notation</span></a><ul class=toc><li><a href=#paint-sources><span class=secno>1.2.1</span> <span class=content>
Paint Sources</span></a><li><a href=#elementsources><span class=secno>1.2.2</span> <span class=content>
Using Out-Of-Document Sources: the <code>ElementSources</code> interface</span></a><li><a href=#element-cycles><span class=secno>1.2.3</span> <span class=content>
Cycle Detection</span></a></ul></ul><li><a href=#gradients><span class=secno>2</span> <span class=content>
Gradients</span></a><ul class=toc><li><a href=#conic-gradients><span class=secno>2.1</span> <span class=content>
Conic Gradients: the <span class=css data-link-type=maybe title=conic-gradient()>conic-gradient()</span> notation</span></a><li><a href=#repeating-gradients><span class=secno>2.2</span> <span class=content>
Repeating Gradients: the <span class=css data-link-type=maybe title=repeating-linear-gradient()>repeating-linear-gradient()</span>, <span class=css data-link-type=maybe title=repeating-radial-gradient()>repeating-radial-gradient()</span>, and <span class=css data-link-type=maybe title=repeating-conic-gradient()>repeating-conic-gradient()</span> notations</span></a><li><a href=#color-stop-syntax><span class=secno>2.3</span> <span class=content>
Gradient Color-Stops</span></a></ul><li><a href=#conformance><span class=secno></span> <span class=content>
Conformance</span></a><ul class=toc><li><a href=#conventions><span class=secno></span> <span class=content>
Document conventions</span></a><li><a href=#conformance-classes><span class=secno></span> <span class=content>
Conformance classes</span></a><li><a href=#partial><span class=secno></span> <span class=content>
Partial implementations</span></a><li><a href=#experimental><span class=secno></span> <span class=content>
Experimental implementations</span></a><li><a href=#testing><span class=secno></span> <span class=content>
Non-experimental implementations</span></a></ul><li><a href=#references><span class=secno></span> <span class=content>References</span></a><ul class=toc><li><a href=#normative><span class=secno></span> <span class=content>Normative References</span></a></ul><li><a href=#index><span class=secno></span> <span class=content>Index</span></a><li><a href=#issues-index><span class=secno></span> <span class=content>Issues Index</span></a></ul></div>
<h2 class="heading settled" data-level=1 id=image-values><span class=secno>1. </span><span class=content>Images Values: the <a class="production css" data-link-type=type title="<image>"><image></a> type</span><a class=self-link href=#image-values></a></h2>
<h3 class="heading settled" data-level=1.1 id=image-notation><span class=secno>1.1. </span><span class=content>Image Fallbacks and Annotations: the <a class=css data-link-type=maybe href=#funcdef-image title=image()>image()</a> notation</span><a class=self-link href=#image-notation></a></h3>
<p>The <a class=css data-link-type=maybe href=#funcdef-image title=image()>image()</a> notation is defined as:</p>
<pre class=prod><dfn data-dfn-type=function data-export="" id=funcdef-image>image()<a class=self-link href=#funcdef-image></a></dfn> = image( <a class=production data-link-type=type href=#typedef-image-tags title="<image-tags>"><image-tags></a><a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-opt title=?>?</a> [ <a class=production data-link-type=type href=#typedef-image-src title="<image-src>"><image-src></a><a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-opt title=?>?</a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-comma title=,>,</a> <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-color-3/#valuea-def-color title="<color>"><color></a><a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-opt title=?>?</a> ]<a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-req title=!>!</a> )
<dfn data-dfn-type=type data-export="" id=typedef-image-tags><image-tags><a class=self-link href=#typedef-image-tags></a></dfn> = [ ltr <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> rtl ]
<dfn data-dfn-type=type data-export="" id=typedef-image-src><image-src><a class=self-link href=#typedef-image-src></a></dfn> = [ <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#url-value title="<url>"><url></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#string-value title="<string>"><string></a> ]
</pre>
<h4 class="heading settled" data-level=1.1.1 id=bidi-images><span class=secno>1.1.1. </span><span class=content>Bidi-sensitive Images</span><a class=self-link href=#bidi-images></a></h4>
<p>Before listing any <code><image-src>s</code>,
the author may specify a directionality for the image,
similar to adding a <code>dir</code> attribute to an element in HTML.
If a directional image is used on or in an element with opposite <a href=http://www.w3.org/TR/CSS21/visuren.html#propdef-direction>direction</a>,
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>
<p class=note>Note: Absent this declaration,
images default to no directionality at all,
and thus don’t care about the directionality of the surrounding element.</p>
<div class=example>
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:
<pre><ul style="list-style-image: image(ltr 'arrow.png');">
<li dir='ltr'>My bullet is on the left!</li>
<li dir='rtl'>MY BULLET IS ON THE RIGHT!</li>
</ul>
</pre>
<p>This should render something like:</p>
<pre>⇒ My bullet is on the left!
!THGIR EHT NO SI TELLUB YM ⇐
</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 class="heading settled" data-level=1.2 id=element-notation><span class=secno>1.2. </span><span class=content>
Using Elements as Images: the <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> notation</span><a class=self-link href=#element-notation></a></h3>
<p>The <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> 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.</p>
<p class=note>Note: The <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> function only reproduces the <em>appearance</em> of the referenced element,
not the actual content and its structure.
Authors should only use this for decorative purposes,
and must not use <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> to reproduce an element with significant content across the page.
Instead, just insert multiple copies of the element into the document.</p>
<p>The syntax for <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> is:</p>
<pre class=prod><dfn data-dfn-type=function data-export="" id=funcdef-element>element()<a class=self-link href=#funcdef-element></a></dfn> = element( <a class=production data-link-type=type href=http://dev.w3.org/csswg/selectors-4/#typedef-id-selector title="<id-selector>"><id-selector></a> )</pre>
<p>where <a class="production css" data-link-type=type href=http://dev.w3.org/csswg/selectors-4/#typedef-id-selector title="<id-selector>"><id-selector></a> is an ID selector <a data-biblio-type=normative data-link-type=biblio href=#biblio-select title=SELECT>[SELECT]</a>.</p>
<p class=issue id=issue-90473f0b><a class=self-link href=#issue-90473f0b></a>
Do we need to be able to refer to elements in external documents
(such as SVG paint servers)?
Or is it enough to just use url() for this?
<p class=issue id=issue-1449f72e><a class=self-link href=#issue-1449f72e></a>
This name conflicts with a somewhat similar function in GCPM.
This needs to be resolved somehow.
<p class=issue id=issue-99f17c20><a class=self-link href=#issue-99f17c20></a>
Want the ability to do "reflections" of an element,
either as a background-image on the element or in a pseudo-element.
This needs to be specially-handled to avoid triggering the cycle-detection.
<p class=issue id=issue-69699ad7><a class=self-link href=#issue-69699ad7></a>
When we have overflow:paged,
how can we address a single page in the view?
<p>The <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> function references the element matched by its argument.
The ID is first looked up in the <a data-link-type=idl href=#dom-css-elementsources title=elementSources>elementSources</a> map,
as described in that section.
If it’s not found,
it’s then matched against the document.
If multiple elements are matched,
the function references the first such element.</p>
<p>The image represented by the <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> function can vary based on whether the element is visible in the document:</p>
<dl>
<dt>
an <a data-link-type=dfn href=#element-not-rendered title=element-not-rendered>element that is rendered</a>,
is not a descendant of a replaced element,
and generates a <a data-link-spec=css21 data-link-type=dfn href=http://dev.w3.org/csswg/css2/visuren.html#x44 title="stacking context">stacking context</a>
<dd>
The function represents an image with its intrinsic size equal to the <dfn data-dfn-type=dfn data-export="" id=decorated-bounding-box>decorated bounding box<a class=self-link href=#decorated-bounding-box></a></dfn> of the referenced element:
<ul>
<li>
for an element rendered using a CSS rendering model,
the <a data-link-type=dfn href=#decorated-bounding-box title="decorated bounding box">decorated bounding box</a> is the smallest axis-aligned rectangle
that contains the <a href=http://www.w3.org/TR/2011/CR-css3-background-20110215/#border-image-area>border image areas</a> of all the fragments of the principal box
<li>
for an element rendered using the SVG rendering model,
<a href=http://www.w3.org/TR/SVGTiny12/intro.html#TermDecoratedBoundingBox>the decorated bounding box is defined by SVG</a>
</ul>
<p class=note>Note: Because images clip anything outside their bounds by default,
this means that decorations that extend outside the <a data-link-type=dfn href=#decorated-bounding-box title="decorated bounding box">decorated bounding box</a>,
like box shadows,
may be clipped.</p>
<p>The image is constructed by rendering the referenced element and its descendants
(at the same size that they would be in the document)
over an infinite <span class=css>transparent</span> canvas,
positioned so that the edges of the <a data-link-type=dfn href=#decorated-bounding-box title="decorated bounding box">decorated bounding box</a> are flush with the edges of the image.</p>
<p class=issue id=issue-88986af5><a class=self-link href=#issue-88986af5></a>
Requiring some degree of stacking context on the element appears to be required for an efficient implementation.
Do we need a full stacking context, or just a pseudo-stacking context?
Should it need to be a stacking context normally,
or can we just render it as a stacking context when rendering it to element()?
<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. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3-transforms title=CSS3-TRANSFORMS>[CSS3-TRANSFORMS]</a></p>
<p>If the referenced element is broken across pages,
the element is displayed as if the page content areas were joined flush in the pagination direction,
with pages' edges corresponding to the initial containing block’s start edge aligned.
<span class=note>Elements broken across lines or columns are just rendered with their <a data-link-type=dfn href=#decorated-bounding-box title="decorated bounding box">decorated bounding box</a>.</span></p>
<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>
<div class=example>
<p>As a somewhat silly example, a <code><p></code> 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>
<p><img alt="" src=images/element-function.png></p>
</div>
<dt>an <a data-link-type=dfn href=#element-not-rendered title=element-not-rendered>element that is not rendered</a>, but which provides a <a data-link-type=dfn href=#paint-source title="paint source">paint source</a>
<dd>
The function represents an image with the intrinsic size and appearance of the <a data-link-type=dfn href=#paint-source title="paint source">paint source</a>.
The host language defines the size and appearance of paint sources.
<div class=example>
For example, the <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> function can reference an SVG <code><pattern></code> element in an HTML document:
<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 <code><canvas></code>, <code><img></code>, and <code><video></code>,
provide a paint source.
This means that CSS can, for example,
reference a canvas that’s being drawn into,
but not displayed in the page:</p>
<pre><!DOCTYPE html>
<script>
var canvas = document.querySelector('#animated-bullet');
canvas.width = 20; canvas.height = 20;
drawAnimation(canvas);
</script>
<canvas id='animated-bullet' style='display:none'></canvas>
<ul style="list-style-image: element(#animated-bullet);">
<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>
<dt>anything else
<dd>
<p>The function represents an <a data-link-type=dfn title="invalid image">invalid image</a>.</p>
<div class=example>
<p>For example, all of the following <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> uses will result in a transparent background:</p>
<pre><!DOCTYPE html>
<p id='one' style="display:none;">one</p>
<iframe src="http://example.com">
<p id='two'>I’m fallback content!</p>
</iframe>
<ul>
<li style="background: element(#one);">
A display:none element isn’t rendered, and a P element
doesn’t provide a paint source.
</li>
<li style="background: element(#two);">
The descendants of a replaced element like an IFRAME
can’t be used in element() either.
</li>
<li style="background: element(#three);">
There’s no element with an id of "three", so this also
gets rendered as a transparent image.
</li>
</ul>
</pre>
</div>
</dl>
<p>An element is <dfn data-dfn-type=dfn data-export="" id=element-not-rendered title=element-not-rendered>not rendered<a class=self-link href=#element-not-rendered></a></dfn> if it does not have an associated box.
This can happen, for example,
if the element or an ancestor is <span class=css>display:none</span>.
Host languages may define additional ways in which an element can be considered not rendered;
for example, in SVG,
any descendant of a <code><defs></code> element is considered to be not rendered.</p>
<div class=example>
<p>The <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> 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 = ...;
document.querySelector('#prev-slide').id = '';
document.querySelector('#next-slide').id = '';
currentSlide.previousElementSibling.id = 'prev-slide';
currentSlide.nextElementSibling.id = 'next-slide';
}
</script>
<style>
#prev-preview, #next-preview {
position: fixed;
...
}
#prev-preview { background: element(#prev-slide); }
#next-preview { background: element(#next-slide); }
</style>
<a id='prev-preview'>Previous Slide</a>
<a id='next-preview'>Next Slide</a>
<section class='slide'>...</section>
<section class='slide current-slide'>...</section>
...
</pre>
<p>In this example, the <code>navigateSlides</code> function updates the ids of 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 <a class=c
8229
ss data-link-type=maybe href=#funcdef-element title=element()>element()</a> 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>
</div>
<h4 class="heading settled" data-level=1.2.1 id=paint-sources><span class=secno>1.2.1. </span><span class=content>
Paint Sources</span><a class=self-link href=#paint-sources></a></h4>
<p>Host languages may define that some elements provide a <dfn data-dfn-type=dfn data-export="" id=paint-source>paint source<a class=self-link href=#paint-source></a></dfn>.
Paint sources have an intrinsic appearance and can obtain a <a data-link-type=dfn title="concrete object size">concrete object size</a>
without having to do layout or rendering,
and so may be used as images even when they’re <a data-link-type=dfn href=#element-not-rendered title=element-not-rendered>not rendered</a>.</p>
<p>In HTML, the <code><img></code>, <code><video></code>, and <code><canvas></code> elements provide paint sources
(defined in each element’s section in <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/>HTML5</a>).</p>
<p>In SVG, any element that provides a <a href=http://www.w3.org/TR/SVG/pservers.html>paint server</a> provides a paint source.
<span class=note>Note: In SVG1.1,
the <code><linearGradient></code>,
<code><radialGradient></code>,
and <code><pattern></code> elements
provide paint sources.</span>
They are drawn as described in the spec,
with the coordinate systems defined as follows:</p>
<dl>
<dt>objectBoundingBox
<dd>
The coordinate system has its origin at the top left corner of the rectangle defined by the <a data-link-type=dfn title="concrete object size">concrete object size</a> that it’s being drawn into,
and the same width and height as the <a data-link-type=dfn title="concrete object size">concrete object size</a>.
A single <a href=http://www.w3.org/TR/SVG/coords.html#Units>user coordinate</a> is the width and height of the <a data-link-type=dfn title="concrete object size">concrete object size</a>.
<dt>userSpaceOnUse
<dd>
The coordinate system has its origin at the top left corner of the rectangle defined by the <a data-link-type=dfn title="concrete object size">concrete object size</a> that it’s being drawn into,
and the same width and height as the <a data-link-type=dfn title="concrete object size">concrete object size</a>.
<a href=http://www.w3.org/TR/SVG/coords.html#Units>User coordinates</a> are sized equivalently to the CSS <span class=css>px</span> unit.
</dl>
<p class=note>Note: It is expected that a future version of this module will define ways to refer to paint sources in external documents,
or ones that are created solely by script and never inserted into a document at all.</p>
<h4 class="heading settled" data-level=1.2.2 id=elementsources><span class=secno>1.2.2. </span><span class=content>
Using Out-Of-Document Sources: the <code>ElementSources</code> interface</span><a class=self-link href=#elementsources></a></h4>
<p>The <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> function normally selects elements within a document,
but elements that provide a <a data-link-type=dfn href=#paint-source title="paint source">paint source</a> don’t necessarily need to be in-document.
For example, an HTML <code><canvas></code> element can be created, maintained, and drawn into entirely in script,
with no need for it to be inserted into the document directly.</p>
<p>All that’s needed is a way to refer to the element,
as an ID selector cannot select elements outside of the document.
The <a data-link-type=idl href=#dom-css-elementsources title=elementSources>elementSources</a> Map object provides this.</p>
<pre class=idl>partial interface <dfn class=idl-code data-dfn-type=interface data-export="" data-global-name="" id=dom-css>CSS<a class=self-link href=#dom-css></a></dfn> {
[SameObject] readonly attribute <a data-link-type=idl title=Map>Map</a> <dfn class=idl-code data-dfn-for=CSS data-dfn-type=attribute data-export="" data-global-name="CSS<interface>/elementsources<attribute>" data-readonly="" data-type="Map " id=dom-css-elementsources>elementSources<a class=self-link href=#dom-css-elementsources></a></dfn>;
};
</pre>
<p>Any entries in the <a data-link-type=idl href=#dom-css-elementsources title=elementSources>elementSources</a> map with a string key
and a value that is an object providing a <a data-link-type=dfn href=#paint-source title="paint source">paint source</a>
are made available to the <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> function.</p>
<p>Whenever <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> uses an <a class="production css" data-link-type=type href=http://dev.w3.org/csswg/selectors-4/#typedef-id-selector title="<id-selector>"><id-selector></a>,
the ID’s value (without the leading <code>#</code> character)
is first looked up in the <a data-link-type=idl href=#dom-css-elementsources title=elementSources>elementSources</a> map:</p>
<ul>
<li>
If it’s found,
and the object associated with it provides a <a data-link-type=dfn href=#paint-source title="paint source">paint source</a>,
the <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> function represents that paint source.
<li>
If it’s found,
but the object associated with it <em>doesn’t</em> provide a <a data-link-type=dfn href=#paint-source title="paint source">paint source</a>,
the <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> function represent an <a data-link-type=dfn title="invalid image">invalid image</a>.
<li>
If the ID isn’t found in the map at all,
it’s then looked for in the document as normal.
</ul>
<p class=issue id=issue-e72c9f56><a class=self-link href=#issue-e72c9f56></a>
This reuse of the ID selector matches Moz behavior.
I’m trying to avoid slapping a <a class="production css" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>"><custom-ident></a> right in the beginning of the grammar,
as that eats too much syntax-space.
Another possibility, though, is to start the value with a language-defined keyword
<em>followed by</em> a <a class="production css" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>"><custom-ident></a>,
like <span class=css>element(external fancy)</span> or something.
Naming suggestions welcome.
<div class=example>
For example, fancy animating backgrounds can be done with an external canvas:
<pre><script>
var bg = document.createElement('canvas');
bg.height = 200;
bg.width = 1000;
drawFancyBackground(bg);
CSS.elementSources.set('fancy', bg);
</script>
<style>
h1 {
background-image: element(#fancy);
}
</style>
</pre>
<p>As the "fancy" canvas is drawn into and animated,
the backgrounds of all the H1 elements will automatically update in tandem.</p>
<p>Note that the <a data-link-type=idl href=#dom-css-el
8097
ementsources title=elementSources>elementSources</a> map is consulted <em>before</em> the document
to match the ID selector,
so even if there’s an element in the document that would match <span class=css>#fancy</span>,
the backgrounds will still predictably come from the <a data-link-type=idl href=#dom-css-elementsources title=elementSources>elementSources</a> value instead.</p>
</div>
<h4 class="heading settled" data-level=1.2.3 id=element-cycles><span class=secno>1.2.3. </span><span class=content>
Cycle Detection</span><a class=self-link href=#element-cycles></a></h4>
<p>The <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> 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>The dependency graph consists of edges such that:</p>
<ul>
<li>
every element depends on its children
<li>
for any element A with a property using the <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> function pointing to an element B,
A depends on B
<li>
if a host language defines a way for elements to refer to the rendering of other elements,
the referencing element depends on the referenced element.
For example, in SVG,
a <code><use></code> element depends on the element it referenced.
</ul>
<p>If the graph contains a cycle,
any <a class=css data-link-type=maybe href=#funcdef-element title=element()>element()</a> functions participating in the cycle are <a data-link-type=dfn title="invalid images">invalid images</a>.</p>
<h2 class="heading settled" data-level=2 id=gradients><span class=secno>2. </span><span class=content>
Gradients</span><a class=self-link href=#gradients></a></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 gradient notations 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 <a class="production css" data-link-type=type href=#typedef-gradient title="<gradient>"><gradient></a> is:</p>
<pre class=prod><dfn data-dfn-type=type data-export="" id=typedef-gradient><gradient><a class=self-link href=#typedef-gradient></a></dfn> = [
<a class=production data-link-type=function title=linear-gradient()><linear-gradient()></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class=production data-link-type=function href=#funcdef-repeating-linear-gradient title=repeating-linear-gradient()><repeating-linear-gradient()></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a>
<a class=production data-link-type=function title=radial-gradient()><radial-gradient()></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class=production data-link-type=function href=#funcdef-repeating-radial-gradient title=repeating-radial-gradient()><repeating-radial-gradient()></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a>
<a class=production data-link-type=function href=#funcdef-conic-gradient title=conic-gradient()><conic-gradient()></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class=production data-link-type=function href=#funcdef-repeating-conic-gradient title=repeating-conic-gradient()><repeating-conic-gradient()></a> ]
</pre>
<div class=example>
<p>As with the other <a class="production css" data-link-type=type title="<image>"><image></a> 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><code>list-style-image: radial-gradient(circle, #006, #00a 90%, #0000af 100%, white 100%)</code>
</ul>
</div>
<p>A gradient is drawn into a box with the dimensions of the <a data-link-type=dfn title="concrete object size">concrete object size</a>,
referred to as the <dfn data-dfn-type=dfn data-export="" id=gradient-box>gradient box<a class=self-link href=#gradient-box></a></dfn>.
However, the gradient itself has no <a data-link-type=dfn title="intrinsic dimensions">intrinsic dimensions</a>.</p>
<div class=example>
For example, if you use a gradient as a background,
by default the gradient will draw into a <a data-link-type=dfn href=#gradient-box title="gradient box">gradient box</a> the size of the element’s padding box.
If <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-backgrounds-3/#background-size title=background-size>background-size</a> is explicitly set to a value such as <span class=css>100px 200px</span>,
then the <a data-link-type=dfn href=#gradient-box title="gradient box">gradient box</a> will be 100px wide and 200px tall.
Similarly, for a gradient used as a <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-lists-3/#propdef-list-style-image title=list-style-image>list-style-image</a>,
the box would be a 1em square,
which is the <a data-link-type=dfn title="default object size">default object size</a> for that property.
</div>
<p>Gradients are specified by defining the <dfn data-dfn-type=dfn data-noexport="" id=starting-point>starting point<a class=self-link href=#starting-point></a></dfn> and <dfn data-dfn-type=dfn data-noexport="" id=ending-point>ending point<a class=self-link href=#ending-point></a></dfn>
of a <dfn data-dfn-type=dfn data-export="" id=gradient-line>gradient line<a class=self-link href=#gradient-line></a></dfn>
(which, depending on the type of gradient,
may be technically a line, or a ray, or a spiral),
and then specifying colors at points along this line.
The colors are smoothly blended to fill in the rest of the line,
and then each type of gradient defines how to use the color of the <a data-link-type=dfn href=#gradient-line title="gradient line">gradient line</a> to produce the actual gradient.</p>
<h3 class="heading settled" data-level=2.1 id=conic-gradients><span class=secno>2.1. </span><span class=content>
Conic Gradients: the <a class=css data-link-type=maybe href=#funcdef-conic-gradient title=conic-gradient()>conic-gradient()</a> notation</span><a class=self-link href=#conic-gradients></a></h3>
<p>A conic gradient starts by specifying the center of a circle,
similar to radial gradients,
except that conic gradient color-stops are placed <em>around</em> the circumference of the circle,
rather than on a line emerging from the center,
causing the color to smoothly transition as you spin around the center,
rather than as you progress outward from the center.</p>
<p>A conic gradient is specified by indicating the center of the gradient,
and then specifying a list of color-stops.
Unlike linear and radial gradients,
whose color-stops are placed by specifying a <a class="production css" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a>,
the color-stops of a conic gradient are specified with an <a class="production css" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#angle-value title="<angle>"><angle></a>.
Rays are then drawn emerging from the center and pointing in all directions,
with the color of each ray equal to the color of the gradient-line where they intersect it.</p>
<p class=note>Note: These gradients are called "conic" or "conical"
because, if the color stops are chosen to be significantly lighter on one side than the other,
it produces a pattern that looks like a cone observed from above.</p>
<h4 class="no-toc heading settled" data-level=2.1.1 id=conic-gradient-syntax><span class=secno>2.1.1. </span><span class=content>
<a class=css data-link-type=maybe href=#funcdef-conic-gradient title=conic-gradient()>conic-gradient()</a> Syntax</span><a class=self-link href=#conic-gradient-syntax></a></h4>
<p>The syntax for a conic gradient is:</p>
<pre class=prod><dfn data-dfn-type=function data-export="" id=funcdef-conic-gradient>conic-gradient()<a class=self-link href=#funcdef-conic-gradient></a></dfn> = conic-gradient(
[ at <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-backgrounds-3/#position title="<position>"><position></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-comma title=,>,</a> ]<a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-opt title=?>?</a>
<a class=production data-link-type=type href=#typedef-angular-color-stop-list title="<angular-color-stop-list>"><angular-color-stop-list></a>
)
</pre>
<p>The <a class="production css" data-link-type=type href=http://dev.w3.org/csswg/css-backgrounds-3/#position title="<position>"><position></a> argument is defined in [!CSS3VAL],
and is resolved using the center-point as the object area
and the gradient box as the positioning area.
If this argument is omitted,
it defaults to 'at center'.</p>
<p class=issue id=issue-42102e31><a class=self-link href=#issue-42102e31></a>
Anything else that might be useful? Defining the shape of the gradient as elliptical, perhaps?
<h4 class="no-toc heading settled" data-level=2.1.2 id=conic-color-stops><span class=secno>2.1.2. </span><span class=content>
Placing Color Stops</span><a class=self-link href=#conic-color-stops></a></h4>
<p>Color stops are placed on a <a data-link-type=dfn href=#gradient-line title="gradient line">gradient line</a> that curves around the center in a circle,
with both the 0% and 100% locations at 0deg.
Just like linear gradients,
0deg points to the top of the page,
and increasing angles correspond to clockwise movement around the circle.</p>
<p class=note>Note: It may be more helpful to think of the gradient line as forming a spiral,
where only the segment from 0deg to 360deg is rendered.
This avoids any confusion about "overlap" when you have angles outside of the rendered region.</p>
<p>A color-stop can be placed at a location before 0% or after 100%;
though these regions are never directly consulted for rendering,
color stops placed there can affect the color of color-stops within the rendered region
through interpolation or repetition (see <a href=#repeating-gradients>repeating gradients</a>).
For example, <span class=css>conic-gradient(red -50%, yellow 150%)</span> produces a conic gradient
that starts with a reddish-orange color at 0deg (specifically, #f50),
and transitions to an orangish-yellow color at 360deg (specifically, #fa0).</p>
<p>The color of the gradient at any point is determined by first finding the unique ray
anchored at the center of the gradient that passes through the given point.
The point’s color is then the color of the <a data-link-type=dfn href=#gradient-line title="gradient line">gradient line</a> at the location where this ray intersects it.</p>
<h4 class="no-toc heading settled" data-level=2.1.3 id=conic-gradient-examples><span class=secno>2.1.3. </span><span class=content>
Conic Gradient Examples</span><a class=self-link href=#conic-gradient-examples></a></h4>
<p class=issue id=issue-57d440f3><a class=self-link href=#issue-57d440f3></a>
Produce examples.
Better yet, strike this section, and intermix some examples into the sections above.
Do this for the other two types of gradients as well.
<h3 class="heading settled" data-level=2.2 id=repeating-gradients><span class=secno>2.2. </span><span class=content>
Repeating Gradients: the <a class=css data-link-type=maybe href=#funcdef-repeating-linear-gradient title=repeating-linear-gradient()>repeating-linear-gradient()</a>, <a class=css data-link-type=maybe href=#funcdef-repeating-radial-gradient title=repeating-radial-gradient()>repeating-radial-gradient()</a>, and <a class=css data-link-type=maybe href=#funcdef-repeating-conic-gradient title=repeating-conic-gradient()>repeating-conic-gradient()</a> notations</span><a class=self-link href=#repeating-gradients></a></h3>
<p>In addition to <span class=css>linear-gradient()</span>, <span class=css>radial-gradient()</span>, and <a class=css data-link-type=maybe href=#funcdef-conic-gradient title=conic-gradient()>conic-gradient()</a>,
this specification defines <dfn class=css data-dfn-type=function data-export="" id=funcdef-repeating-linear-gradient>repeating-linear-gradient()<a class=self-link href=#funcdef-repeating-linear-gradient></a></dfn>,
<dfn class=css data-dfn-type=function data-export="" id=funcdef-repeating-radial-gradient>repeating-radial-gradient()<a class=self-link href=#funcdef-repeating-radial-gradient></a></dfn>,
and <dfn class=css data-dfn-type=function data-export="" id=funcdef-repeating-conic-gradient>repeating-conic-gradient()<a class=self-link href=#funcdef-repeating-conic-gradient></a></dfn> values.
These notations take the same values
and are interpreted the same
as their respective non-repeating siblings defined previously.</p>
<div class=example>
<pre>repeating-conic-gradient(at 20%, white 0deg, white 20deg, red 20deg, red 40deg)</pre>
<p class=issue id=issue-091fbe43><a class=self-link href=#issue-091fbe43></a>Insert rendering here.
</div>
<h3 class="heading settled" data-level=2.3 id=color-stop-syntax><span class=secno>2.3. </span><span class=content>
Gradient Color-Stops</span><a class=self-link href=#color-stop-syntax></a></h3>
<pre class=prod><dfn data-dfn-type=type data-export="" id=typedef-color-stop-list><color-stop-list><a class=self-link href=#typedef-color-stop-list></a></dfn> =
[ <a class=production data-link-type=type href=#typedef-linear-color-stop title="<linear-color-stop>"><linear-color-stop></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-comma title=,>,</a> <a class=production data-link-type=type href=#typedef-linear-color-hint title="<linear-color-hint>"><linear-color-hint></a><a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-opt title=?>?</a> ]<a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-comma title=#>#</a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-comma title=,>,</a> <a class=production data-link-type=type href=#typedef-linear-color-stop title="<linear-color-stop>"><linear-color-stop></a>
<dfn data-dfn-type=type data-export="" id=typedef-linear-color-stop><linear-color-stop><a class=self-link href=#typedef-linear-color-stop></a></dfn> = <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-color-3/#valuea-def-color title="<color>"><color></a> && <a class=production data-link-type=type href=#typedef-color-stop-length title="<color-stop-length>"><color-stop-length></a>
<dfn data-dfn-type=type data-export="" id=typedef-linear-color-hint><linear-color-hint><a class=self-link href=#typedef-linear-color-hint></a></dfn> = <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#percentage-value title="<percentage>"><percentage></a>
<dfn data-dfn-type=type data-export="" id=typedef-color-stop-length><color-stop-length><a class=self-link href=#typedef-color-stop-length></a></dfn> = [ <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#percentage-value title="<percentage>"><percentage></a> ]{1<a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-comma title=,>,</a>2}
<dfn data-dfn-type=type data-export="" id=typedef-angular-color-stop-list><angular-color-stop-list><a class=self-link href=#typedef-angular-color-stop-list></a></dfn> =
[ <a class=production data-link-type=type href=#typedef-angular-color-stop title="<angular-color-stop>"><angular-color-stop></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-comma title=,>,</a> <a class=production data-link-type=type href=#typedef-angular-color-hint title="<angular-color-hint>"><angular-color-hint></a><a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-opt title=?>?</a> ]<a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-comma title=#>#</a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-comma title=,>,</a> <a class=production data-link-type=type href=#typedef-angular-color-stop title="<angular-color-stop>"><angular-color-stop></a>
<dfn data-dfn-type=type data-export="" id=typedef-angular-color-stop><angular-color-stop><a class=self-link href=#typedef-angular-color-stop></a></dfn> = <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-color-3/#valuea-def-color title="<color>"><color></a> && <a class=production data-link-type=type href=#typedef-color-stop-angle title="<color-stop-angle>"><color-stop-angle></a><a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-opt title=?>?</a>
<dfn data-dfn-type=type data-export="" id=typedef-angular-color-hint><angular-color-hint><a class=self-link href=#typedef-angular-color-hint></a></dfn> = <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#angle-value title="<angle>"><angle></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#percentage-value title="<percentage>"><percentage></a>
<dfn data-dfn-type=type data-export="" id=typedef-color-stop-angle><color-stop-angle><a class=self-link href=#typedef-color-stop-angle></a></dfn> = [ <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#angle-value title="<angle>"><angle></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class=production data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#percentage-value title="<percentage>"><percentage></a> ]{1<a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-comma title=,>,</a>2}
<dfn data-dfn-type=type data-export="" id=typedef-color-stop><color-stop><a class=self-link href=#typedef-color-stop></a></dfn> = <a class=production data-link-type=type href=#typedef-color-stop-length title="<color-stop-length>"><color-stop-length></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class=production data-link-type=type href=#typedef-color-stop-angle title="<color-stop-angle>"><color-stop-angle></a>
</pre>
<div class=railroad><svg class=railroad-diagram height=121 viewBox="0 0 597 121" width=597>
<g transform="translate(.5 .5)">
<path d="M 20 50 v 20 m 10 -20 v 20 m -10 -10 h 20.5">
</path><path d="M40 60h10">
</path><g>
<path d="M50 60h0.0">
</path><path d="M410.0 60h0.0">
</path><path d="M50.0 60h10">
</path><g>
<path d="M60.0 60h0.0">
</path><path d="M400.0 60h0.0">
</path><path d="M60.0 60h10">
</path><g>
<path d="M70.0 60h0.0">
</path><path d="M186.0 60h0.0">
</path><rect height=22 width=116 x=70.0 y=49>
</rect><text x=128.0 y=64>
<color-stop></text></g><path d="M186.0 60h10">
</path><path d="M196.0 60h10">
</path><g>
<path d="M206.0 60h0.0">
</path><path d="M234.0 60h0.0">
</path><rect height=22 rx=10 ry=10 width=28 x=206.0 y=49>
</rect><text x=220.0 y=64>
,</text></g><path d="M234.0 60h10">
</path><g>
<path d="M244.0 60h0.0">
</path><path d="M400.0 60h0.0">
</path><path d="M244.0 60a10 10 0 0 0 10 -10v0a10 10 0 0 1 10 -10">
</path><g>
<path d="M264.0 40h0.0">
</path><path d="M380.0 40h0.0">
</path><rect height=22 width=116 x=264.0 y=29>
</rect><text x=322.0 y=44>
<color-hint></text></g><path d="M380.0 40a10 10 0 0 1 10 10v0a10 10 0 0 0 10 10">
</path><path d="M244.0 60h20">
</path><g>
<path d="M264.0 60h116">
</path></g><path d="M380.0 60h20">
</path></g></g><path d="M400.0 60h10">
</path><path d="M60.0 60a10 10 0 0 0 -10 10v10a10 10 0 0 0 10 10">
</path><g>
<path d="M60.0 90h156.0">
</path><path d="M244.0 90h156.0">
</path><rect height=22 rx=10 ry=10 width=28 x=216.0 y=79>
</rect><text x=230.0 y=94>
,</text></g><path d="M400.0 90a10 10 0 0 0 10 -10v-10a10 10 0 0 0 -10 -10">
</path></g><path d="M410 60h10">
</path><path d="M420 60h10">
</path><g>
<path d="M430 60h0.0">
</path><path d="M546.0 60h0.0">
</path><rect height=22 width=116 x=430.0 y=49>
</rect><text x=488.0 y=64>
<color-stop></text></g><path d="M546 60h10">
</path><path d="M 556 60 h 20 m -10 -10 v 20 m 10 -20 v 20">
</path></g></svg></div>
<p class=issue id=issue-cfc5db5e><a class=self-link href=#issue-cfc5db5e></a>
This is past the complexity point where it can be easily understood with just prose.
Add a diagram illustrating the possibilities,
preferably for all three kinds of gradients
(to show off the three shapes of gradient lines).
<p>The colors in gradients are specified using <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>.
A <dfn data-dfn-type=dfn data-export="" id=color-stop>color stop<a class=self-link href=#color-stop></a></dfn> is a combination of a color and one or two positions.
(Depending on the type of gradient, that position can be a length, angle, or percentage.)
While every color stop conceptually has at least one position,
the position can be omitted in the syntax.
(It gets automatically filled in by the user agent; see below for details.)</p>
<p>Between two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> there can be a <dfn data-dfn-type=dfn data-local-title="color hint" data-noexport="" id=color-interpolation-hint>color interpolation hint<a class=self-link href=#color-interpolation-hint></a></dfn>,
which specifies how the colors of the two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> on either side
should be interpolated in the space between them
(by default, they interpolate linearly).
There can only be at most one <a data-link-type=dfn href=#color-interpolation-hint title="color interpolation hint">color interpolation hint</a> between any two given <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>;
using more than that makes the function invalid.</p>
<p>Color stops are organized into a <dfn data-dfn-type=dfn data-export="" id=color-stop-list>color stop list<a class=self-link href=#color-stop-list></a></dfn>,
which is a list of one or more <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>.
The first and last <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> in the list
must have a color
(though their position can be omitted).</p>
<p><a data-link-type=dfn href=#color-stop title="Color stops">Color stops</a> and <a data-link-type=dfn href=#color-interpolation-hint title="color hints">color hints</a> are placed on a <a data-link-type=dfn href=#gradient-line title="gradient line">gradient line</a>,
which defines the colors at every point of a gradient.
The gradient function defines the shape and length of the <a data-link-type=dfn href=#gradient-line title="gradient line">gradient line</a>,
along with its <a data-link-type=dfn href=#starting-point title="starting point">starting point</a> and <a data-link-type=dfn href=#ending-point title="ending point">ending point</a>.</p>
<p><a data-link-type=dfn href=#color-stop title="Color stops">Color stops</a> and <a data-link-type=dfn href=#color-interpolation-hint title="color hints">color hints</a> must be specified in order.
Percentages refer to the length of the <a data-link-type=dfn href=#gradient-line title="gradient line">gradient line</a> between the <a data-link-type=dfn href=#starting-point title="starting point">starting point</a> and <a data-link-type=dfn href=#ending-point title="ending point">ending point</a>,
with 0% being at the starting point
and 100% being at the ending point.
Lengths are measured from the <a data-link-type=dfn href=#starting-point title="starting point">starting point</a> in the direction of the <a data-link-type=dfn href=#ending-point title="ending point">ending point</a> along the <a data-link-type=dfn href=#gradient-line title="gradient line">gradient line</a>.
Angles are measured with 0deg pointing up,
and positive angles corresponding to clockwise rotations from there.</p>
<p><a data-link-type=dfn href=#color-stop title="Color stops">Color stops</a> and <a data-link-type=dfn href=#color-interpolation-hint title="color hints">color hints</a> are usually placed between the <a data-link-type=dfn href=#starting-point title="starting point">starting point</a> and <a data-link-type=dfn href=#ending-point title="ending point">ending point</a>,
but that’s not required;
the gradient line extends infinitely in both directions,
and a <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> or <a data-link-type=dfn href=#color-interpolation-hint title="color hint">color hint</a> can be placed at any position on the <a data-link-type=dfn href=#gradient-line title="gradient line">gradient line</a>.</p>
<p>A <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> with two locations is mostly equivalent
to specifying two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> with the same color,
one for each position.
<span class=note>Specifying two locations makes it easier to create solid-color "stripes" in a gradient,
without having to repeat the color twice.</span></p>
<p>The position of a <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> can be omitted.
This causes the <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> to position itself automatically
between the two surrounding stops.
If multiple stops in a row lack a position,
they space themselves out equally.</p>
<p>The following steps must be applied <em>in order</em> to process the <a class="production css" data-link-type=type href=#typedef-color-stop-list title="<color-stop-list>"><color-stop-list></a>.
After applying these rules,
all <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> and <a data-link-type=dfn href=#color-interpolation-hint title="color hints">color hints</a> will have a definite position and color (if appropriate)
and they will be in ascending order:</p>
<ol>
<li>
If the first <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> does not have a position,
set its position to 0%.
If the last <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> does not have a position,
set its position to 100%.
<li>
If a <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> or <a data-link-type=dfn href=#color-interpolation-hint title="color hint">color hint</a> has a position that is less than the specified position of any <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> or <a data-link-type=dfn href=#color-interpolation-hint title="color hint">color hint</a> before it in the list,
set its position to be equal to the largest specified position of any <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> or <a data-link-type=dfn href=#color-interpolation-hint title="color hint">color hint</a> before it.
<li>
If any <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> still does not have a position,
then, for each run of adjacent <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> without positions,
set their positions so that they are evenly spaced between the preceding and following <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> with positions.
</ol>
<p class=issue id=issue-ffe26cbe><a class=self-link href=#issue-ffe26cbe></a>
This requires us to wait until <em>after</em> layout to do fix-up,
because implied-position stops (set by step 3)
may depend on stops that need layout information to place,
and which may be corrected by step 2.
Swapping steps 2 and 3 would let us interpolate <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> purely at computed-value time,
which is a nice plus,
at the cost of changing behavior from level 3 for some edge cases that triggered fixup.
Make sure this is handled well in the serialization rules.
<p>At each <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> position,
the line is the color of the <a data-link-type=dfn href=#color-stop title="color stop">color stop</a>.
Between two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>,
the line’s color is interpolated between the colors of the two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>,
with the interpolation taking place in premultiplied RGBA space.</p>
<p>By default,
this interpolation is linear—<wbr>at 25%, 50%, or 75% of the distance between two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>,
the color is a 25%, 50%, or 75% blend of the colors of the two stops.</p>
<p>However, if a <a data-link-type=dfn href=#color-interpolation-hint title="color hint">color hint</a> was provided between two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>,
the interpolation is non-linear,
and controlled by the hint:</p>
<ol>
<li>
Determine the location of the <a data-link-type=dfn href=#color-interpolation-hint title="color hint">color hint</a> as a percentage of the distance between the two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>,
denoted as a number between 0 and 1,
where 0 indicates the hint is placed right on the first <a data-link-type=dfn href=#color-stop title="color stop">color stop</a>,
and 1 indicates the hint is placed right on the second <a data-link-type=dfn href=#color-stop title="color stop">color stop</a>.
Let this percentage be <var>H</var>.
<li>
For any given point between the two color stops,
determine the point’s location as a percentage of the distance between the two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>,
in the same way as the previous step.
Let this percentage be <var>P</var>.
<li>
Let <var>C</var>, the color weighting at that point,
be equal to <code>P<sup>log<sub>H</sub>(.5)</sup></code>.
<li>
The color at that point is then a linear blend between the colors of the two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>,
blending <code>(1 - C)</code> of the first stop and <var>C</var> of the second stop.
</ol>
<p class=note>Note: If the hint is placed halfway between the two stops,
this is thus the ordinary linear interpolation.
If the hint is placed anywhere else,
it dictates the position of the "halfway point",
where the color is an equal blend between the two <a data-link-type=dfn href=#color-stop title="color stops">color stops</a>,
and produces smooth, even blends between the <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> and the "halfway point".</p>
<p>Before the first <a data-link-type=dfn href=#color-stop title="color stop">color stop</a>,
the line is the color of the first <a data-link-type=dfn href=#color-stop title="color stop">color stop</a>.
After the last <a data-link-type=dfn href=#color-stop title="color stop">color stop</a>, the line is the color of the last <a data-link-type=dfn href=#color-stop title="color stop">color stop</a>.</p>
<p>If multiple <a data-link-type=dfn href=#color-stop title="color stops">color stops</a> 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>
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>
<pre>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)
8. linear-gradient(red, 25%, white)
=14=>
linear-gradient(red 0%, rgb(100%,50%,50%) 25%, white 100%)
</pre>
</div>
<div class=example>
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:
<pre>linear-gradient(90deg, red, transparent, blue)</pre>
<p>In premultiplied space,
transitions to or from "transparent" always look nice:</p>
<object data=images/gradient2.svg height=100 width=200>(Image requires SVG)</object>
<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 <span class=css>rgba(0,0,0,0)</span>, or transparent black:</p>
<object data=images/gradient3.svg height=100 width=200>(Image requires SVG)</object>
</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 <a data-link-type=dfn href=#color-stop title="color stop">color stop</a> to unintentionally try to move before an earlier one.
For example, the rule <a class=css data-link-type=propdesc href=http://dev.w3.org/csswg/css-backgrounds-3/#background-image title=background-image>background-image: linear-gradient(yellow 100px, blue 50%)</a>
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 <a data-link-type=dfn href=#color-stop title="color stop’s">color stop’s</a> position would be equivalent to "75px",
which precedes the yellow <a data-link-type=dfn href=#color-stop title="color stop">color stop</a>,
and would be corrected to a position of 100px.</p>