forked from ResponsiveImagesCG/picture-element
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.src.html
1390 lines (1383 loc) · 52.4 KB
/
index.src.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>
The picture element
</title>
<style>
.informative {
background-color: rgb(233, 251, 233);
}
figure {
display: block;
border: thin silver solid;
margin: 0.5em;
padding: 0.5em;
text-align: center;
}
figcaption {
font-style: italic;
font-size: smaller;
text-indent: 0;
}
figcaption:before {
font-weight: bold;
counter-increment: figcaption;
content: "Figure " counter(figcaption) ". "
}
ol > li {
margin-bottom: 1em;
}
#conformance dd {
margin-bottom: 1em;
}
pre {
tab-size: 3; /* Reduce indentation. */
}
.informative-subhed {
font-size: 120%;
}
a {
color: blue
}
a:not([href]) {
color: red
}
#open-issues-xhr {
font-size: .9em;
}
#open-issues-xhr li {
padding: .25em 0;
}
#open-issues-xhr .meta {
display: block;
font: normal .8em/1 sans-serif;
padding: .35em 0 0 0;
}
#open-issues-xhr .meta b {
font-weight: normal;
}
#open-issues-xhr .meta span {
display: block;
float: left;
width: 5.5em;
}
/* --- INLINES --- */
em.rfc2119 {
text-transform: lowercase;
font-variant: small-caps;
font-style: normal;
color: #900;
}
h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr, h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
border: none;
}
dfn {
font-weight: bold;
}
a.internalDFN {
color: inherit;
border-bottom: 1px solid #99c;
text-decoration: none;
}
a.externalDFN {
color: inherit;
border-bottom: 1px dotted #ccc;
text-decoration: none;
}
a.bibref {
text-decoration: none;
}
cite .bibref {
font-style: normal;
}
code {
color: #ff4500;
}
/* --- --- */
ol.algorithm {
counter-reset:numsection;
list-style-type: none;
}
ol.algorithm li {
margin: 0.5em 0;
}
ol.algorithm li:before {
font-weight: bold;
counter-increment: numsection;
content: counters(numsection, ".") ") ";
}
/* --- TOC --- */
.toc a, .tof a {
text-decoration: none;
}
.toc li {
list-style-type: none;
padding: .1em 0;
}
a .secno, a .figno {
color: #000;
}
ul.tof, ol.tof {
list-style: none outside none;
}
.caption {
margin-top: 0.5em;
font-style: italic;
}
/* --- TABLE --- */
table.simple {
border-spacing: 0;
border-collapse: collapse;
border-bottom: 3px solid #005a9c;
}
.simple th {
background: #005a9c;
color: #fff;
padding: 3px 5px;
text-align: left;
}
.simple th[scope="row"] {
background: inherit;
color: inherit;
border-top: 1px solid #ddd;
}
.simple td {
padding: 3px 10px;
border-top: 1px solid #ddd;
}
.simple tr:nth-child(even) {
background: #f0f6ff;
}
/* --- DL --- */
.section dd > p:first-child {
margin-top: 0;
}
.section dd > p:last-child {
margin-bottom: 0;
}
.section dd {
margin-bottom: 1em;
}
.section dl.attrs dd, .section dl.eldef dd {
margin-bottom: 0;
}
/* --- EXAMPLES --- */
div.example-title {
min-width: 7.5em;
color: #b9ab2d;
}
div.example-title span {
text-transform: uppercase;
}
aside.example, div.example, div.illegal-example {
padding: 0.5em;
margin: 1em 0;
position: relative;
clear: both;
}
div.illegal-example {
color: red
}
div.illegal-example p {
color: black
}
aside.example, div.example {
padding: .5em;
border-left-width: .5em;
border-left-style: solid;
border-color: #e0cb52;
background: #fcfaee;
}
aside.example div.example {
border-left-width: .1em;
border-color: #999;
background: #fff;
}
aside.example div.example div.example-title {
color: #999;
}
/* --- ISSUES/NOTES --- */
div.issue-title, div.note-title {
padding-right: 1em;
min-width: 7.5em;
color: #b9ab2d;
}
div.issue-title {
color: #e05252;
}
div.note-title {
color: #52e052;
}
div.issue-title span, div.note-title span {
text-transform: uppercase;
}
div.note, div.issue {
margin-top: 1em;
margin-bottom: 1em;
}
.note > p:first-child, .issue > p:first-child {
margin-top: 0
}
.issue, .note {
padding: .5em;
border-left-width: .5em;
border-left-style: solid;
}
div.issue, div.note {
padding: 0.5em;
margin: 1em 0;
position: relative;
clear: both;
}
span.note, span.issue {
padding: .1em .5em .15em;
}
.issue {
border-color: #e05252;
background: #fbe9e9;
}
.note {
border-color: #52e052;
background: #e9fbe9;
}
.stability {
position: fixed;
bottom: 0;
left: 0;
right: 0;
margin: 0 auto 0 auto;
width: 50%;
background: maroon;
color: yellow;
-webkit-border-radius: 1em 1em 0 0;
-moz-border-radius: 1em 1em 0 0;
border-radius: 1em 1em 0 0;
-moz-box-shadow: 0 0 1em #500;
-webkit-box-shadow: 0 0 1em #500;
box-shadow: 0 0 1em red;
padding: 0.5em 1em;
text-align: center;
}
.stability strong {
display: block;
}
.stability input {
-moz-appearance: none;
-webkit-appearance: none;
margin: 0;
border: 0;
padding: 0.25em 0.5em;
background: transparent;
color: black;
position: absolute;
top: -0.5em;
right: 0;
font: 1.25em sans-serif;
text-align: center;
}
.stability input:hover {
color: white;
text-shadow: 0 0 2px black;
}
.stability input:active {
padding: 0.3em 0.45em 0.2em 0.55em;
}
.stability :link, .stability :visited, .stability :link:hover, .stability :visited:hover {
background: transparent;
color: white;
}
</style>
<link rel="stylesheet" href=
"http://www.w3.org/StyleSheets/TR/W3C-[STATUS]">
<!--[if lt IE 9]><script src='http://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]-->
<style class="w3c ricg">
.w3c{
border: 1px solid blue;
}
.ricg{
border: 1px solid red;
}
span, cite{
border: 1px dotted green;
}
span span{
background-color: red;
}
</style>
<link class="w3c" rel="stylesheet" href=
"http://www.w3.org/StyleSheets/TR/W3C-[STATUS]">
<link class="ricg" rel="stylesheet" href=
"http://www.w3.org/StyleSheets/TR/w3c-unofficial.css">
</head>
<body>
<header>
<div class="head">
<p>
<a href="http://responsiveimages.org"><img style="float:right" src=
"https://raw.github.com/ResponsiveImagesCG/meta/master/logo/Web/RICG_logo_small.png"
alt="Responsive Images Community Group"></a> <a href=
"http://www.w3.org/"><img height="48" width="72" alt="W3C" src=
"http://www.w3.org/Icons/w3c_home"></a>
</p>
<h1>
The picture element
</h1>
<h2 class="no-num no-toc">
An HTML extension for adaptive images
</h2>
<h2 class="no-num no-toc w3c">
W3C Working Draft [DATE]
</h2>
<h2 class="no-num no-toc ricg">
Living document - Last updated [DATE]
</h2>
<dl>
<dt>
This Version:
</dt>
<dd class="ricg">
<a href=
"http://picture.responsiveimages.org/">http://picture.responsiveimages.org/</a>
</dd>
<dd class="w3c">
<a href="[VERSION]">[VERSION]</a>
</dd>
<dt class="w3c">
Latest version:
</dt>
<dt class="ricg">
Latest W3C Published Version:
</dt>
<dd>
<a href=
"http://www.w3.org/TR/[SHORTNAME]/">http://www.w3.org/TR/[SHORTNAME]/</a>
</dd>
<dt class="w3c">
Previous version:
</dt>
<dd class="w3c">
None.
</dd>
<dt class="w3c">
Latest Editor's draft:
</dt>
<dd>
<a href=
"http://picture.responsiveimages.org">http://picture.responsiveimages.org</a>
</dd>
<dt>
Participate:
</dt>
<dd>
<a href="http://w3c.responsiveimages.org">Join the Responsive
Images Community Group</a>
</dd>
<dd>
<a href="http://list.responsiveimages.org">Public mailing list</a>
</dd>
<dd>
<a href="irc://irc.w3.org:6665/#respimg">IRC: #respimg on W3C's IRC
server</a>
</dd>
<dd>
<a href="https://twitter.com/respimg">Twitter</a>
</dd>
<dd>
<a href="http://gh.responsiveimages.org">Github</a>
</dd>
<dt>
Version history:
</dt>
<dd>
<a href=
"https://github.com/ResponsiveImagesCG/picture-element/commits/gh-pages">
Github commits</a> (<a href=
"https://github.com/ResponsiveImagesCG/picture-element/commits/gh-pages.atom">RSS</a>)
</dd>
<dd>
<a href="https://twitter.com/respimg_commits">Github commits on
Twitter</a>
</dd>
<dt>
Authors:
</dt>
<dd>
<span>Participants</span> of the Responsive Images Community Group
</dd>
<dt>
Editors:
</dt>
<dd>
<a href="http://marcosc.com">Marcos Cáceres</a>, <a href=
"http://datadriven.com.au">Data.Driven</a>
</dd>
<dd>
<a href="http://matmarquis.com/">Mat Marquis</a>
</dd>
<dd>
<a href="http://blog.yoav.ws/">Yoav Weiss</a>
</dd>
<dd>
Adrian Bateman, <a href="http://www.microsoft.com/">Microsoft
Corporation</a>
</dd>
<dt>
RICG Final Specification Licensing Commitments:
</dt>
<dd>
<a href=
"http://www.w3.org/community/respimg/spec/26/commitments">http://www.w3.org/community/respimg/spec/26/commitments</a>
</dd>
</dl>
<p class="copyright w3c">
<a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
© [YEAR] <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>), 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>
<p class="copyright ricg">
Copyright © [YEAR] the Contributors to the <cite>Use Cases and
Requirements for Standardizing Responsive Images</cite>
Specification, published by the <a href=
"http://www.w3.org/community/respimg/">Responsive Images Community
Group</a> under the <a href=
"https://www.w3.org/community/about/agreements/cla/">W3C Community
Contributor License Agreement (CLA)</a>. A human-readable <a href=
"http://www.w3.org/community/about/agreements/cla-deed/">summary</a>
is available.
</p>
</div>
<hr>
</header>
<h2 class="no-toc no-num">
Abstract
</h2>
<p>
The <code>picture</code> element provides a way to group multiple
versions of an image based on different characteristics (e.g., format,
resolution, cropping, etc.). This allows the user agent to select the
optimum image to present to an end-user based on the user agent's
environmental conditions and constraints.
</p>
<h2 id="status" class="no-toc no-num">
Status of This Document
</h2>
<p>
<em>This section describes the status of this document at the time of its
publication. Other documents may supersede this document. A list of
current W3C publications and the latest revision of this technical report
can be found in the <a href="http://www.w3.org/TR/">W3C technical reports
index</a> at http://www.w3.org/TR/.</em>
</p>
<p class="ricg">
This specification was published by the <a href=
"http://www.w3.org/community/respimg/">Responsive Images Community
Group</a>. It is not a W3C Standard nor is it on the W3C Standards Track.
Please note that under the <a href=
"http://www.w3.org/community/about/agreements/cla/">W3C Community
Contributor License Agreement (CLA)</a> there is a limited opt-out and
other conditions apply. Learn more about <a href=
"http://www.w3.org/community/">W3C Community and Business Groups</a>.
</p>
<div class="note ricg">
<div class="note-title">
<span>Note</span>
</div>
<div class="">
<p>
This specification is under active development and changing
frequently. Please see the list of <a href="#dfn-open-issues" class=
"internalDFN">open issues</a>.
</p>
</div>
</div>
<div class="w3c">
<p class="stability" id="wip">
<strong>This is a work in progress!</strong> For the latest updates
from the HTML WG and <a href="http://responsiveimages.org">RICG</a>,
possibly including important bug fixes, please look at the <a href=
"http://usecases.responsiveimages.org">editor's draft</a> instead. If
you find any bugs, typos, or issues please <a href=
"https://www.w3.org/Bugs/Public/enter_bug.cgi?product=HTML%20WG">file a
bug</a>! <input onclick="closeWarning(this.parentNode)" type="button"
value="X">
</p><script>
function closeWarning(element) {
element.parentNode.removeChild(element);
var date = new Date();
date.setDate(date.getDate()+4);
document.cookie = 'hide-obsolescence-warning=1; expires=' + date.toGMTString();
}
if (getCookie('hide-obsolescence-warning') == '1')
setTimeout(function () { document.getElementById('wip').parentNode.removeChild(document.getElementById('wip')); }, 2000);
</script>
<p>
This is a First Public Working Draft.
</p>
<p>
This document was published by the <a href=
"http://www.w3.org/html/wg/">HTML Working Group</a> as a Working Draft,
but was developed in collaboration with the <a href=
"http://responsiveimages.org">Responsive Images Community Group</a>
(see <a href=
"http://www.w3.org/community/respimg/spec/26/commitments">licensing
commitments</a>). If you are not a HTML working group member and wish
to make comments regarding this document please send them to <a href=
"mailto:[email protected]">[email protected]</a>
(<a href=
"mailto:[email protected]?subject=subscribe">subscribe</a>,
<a href=
"http://lists.w3.org/Archives/Public/public-html-comments/">archives</a>).
If you are a HTML working group member and wish to make comments
regarding this document, please send them to <a href=
"mailto:[email protected]">[email protected]</a> (<a href=
"mailto:[email protected]?subject=subscribe">subscribe</a>,
<a href=
"http://lists.w3.org/Archives/Public/public-html/">archives</a>). All
feedback is welcome.
</p>
<p>
Publication as a Working Draft does not imply endorsement by the W3C
Membership. This is a draft document and may be updated, replaced or
obsoleted by other documents at any time. It is inappropriate to cite
this document as other than work in progress.
</p>
<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/40318/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>.
</p>
</div>
<h2 class="no-num no-toc">
Table of Contents
</h2><!-- toc -->
<h2>
Introduction
</h2>
<p>
<em>This section is non-normative.</em>
</p>
<p>
This specification provides developers with a means to declare multiple
sources for an image, and, through [<cite>CSS3-MEDIAQUERIES</cite>]
(<cite>CSS Media Queries</cite>), it gives developers control as to when
those images are to be presented to a user. This is achieved by
introducing a new <code>picture</code> element to [<cite>HTML</cite>]
that makes use of the <code>source</code> element. The
<code>picture</code> element remains backwards compatible with legacy
user agents by degrading gracefully through <span>fallback content</span>
(i.e., through the <code>img</code> element) while also potentially
providing better accessibility than the existing <code>img</code>
element.
</p>
<p>
By relying on [<cite>CSS3-MEDIAQUERIES</cite>], a user agent can
<em>respond</em> to changes in the browsing environment by selecting the
image source that most closely matches the browsing environment - thus
embodying a technique known as <a href=
"http://en.wikipedia.org/wiki/Responsive_web_design">responsive web
design</a> directly in the HTML markup. <a href=
"http://www.w3.org/TR/css3-mediaqueries/#media1">Media features</a> that
a user agent can potentially respond to include, but are not limited to,
pixel widths and heights, and pixel densities, as well as environmental
lighting conditions, changes in orientation, and changes in media type
such as going from screen to print.
</p>
<p>
This specification also defines the <code>HTMLPictureElement</code>
programming interface, which affords developers a set of attributes and
methods for interacting with <code>picture</code> elements through
ECMAScript.
</p>
<h3>
Example of usage
</h3>
<p>
<em>This section is non-normative.</em>
</p>
<p>
This first sample shows how to combine the <code>picture</code> element
with the source element, while also providing fallback content for legacy
user agents through the <code>img</code> element.
</p>
<div class="example">
<div class="example-title">
<span>Example 1</span>
</div>
<pre class="example">
<picture width="500" height="500">
<source media="(min-width: 45em)" src="large.jpg">
<source media="(min-width: 18em)" src="med.jpg">
<source src="small.jpg">
<img src="small.jpg" alt="" lazyload>
<p>Accessible text</p>
</picture>
</pre>
</div>
<div class="issue">
<div class="issue-title">
<span>Issue 1</span>
</div>
<div class="">
<p>
The following example assumes we can get <a href=
"http://dev.w3.org/html5/srcset/">the <code>srcset</code>
attribute</a> supported on HTML's <code>source</code> element. See
<a href="https://github.com/Wilto/draft-prop/issues/64">issue 64</a>.
</p>
</div>
</div>
<p>
This second example shows how the <code>picture</code> element can be
used with <a href="http://dev.w3.org/html5/srcset/">the
<code>srcset</code> attribute</a> to provide a range of sources suitable
for a given media query:
</p>
<div class="example">
<div class="example-title">
<span>Example 2</span>
</div>
<pre class="example">
<picture width="500" height="500">
<source media="(min-width: 45em)" srcset="large-1.jpg 1x, large-2.jpg 2x">
<source media="(min-width: 18em)" srcset="med-1.jpg 1x, med-2.jpg 2x">
<source srcset="small-1.jpg 1x, small-2.jpg 2x">
<img src="small-1.jpg" alt="" lazyload>
<p>Accessible text</p>
</picture>
</pre>
</div>
<div class="note">
<div class="note-title">
<span>Note</span>
</div>
<div class="">
<p>
The <code>lazyload</code> attribute is used on the <code><img></code> tag in the above examples in order to avoid a download
of that resource when picture is supported.
It enables the user agent to delay the resource's download at least until the resource is added to the DOM, at which point the
user agent can detect that the <code><img></code> element is a child of a <code><picture></code> element.
</p>
</div>
<h3>
Relationship to <code>srcset</code>
</h3>
<p>
The `srcset` attribute allows authors to define various image resources
and “hints” that assist a user agent in determining the most appropriate
image source to display. Given a set of image resources, the user agent
has the option of either following or overriding the author’s
declarations to optimize the user experience based on criteria such as
<a href=
"http://usecases.responsiveimages.org/#resolution-switching">display
density</a>, connection type, <a href=
"http://usecases.responsiveimages.org/#user-control-over-sources">user
preferences</a>, and so on.
</p>
<p>
The `picture` element defines conditions under which the UA should follow
the author's explicit instructions when selecting which resource to
display. This includes image sources with inherent sizes designed to
align with layout variations specified in CSS media queries ( see:
<a href="http://usecases.responsiveimages.org/#design-breakpoints">design
breakpoints</a>, <a href=
"http://usecases.responsiveimages.org/#matching-media-features-and-media-types">
media features and types</a> and <a href=
"http://usecases.responsiveimages.org/#relative-units">relative units</a>
) or <a href=
"http://usecases.responsiveimages.org/#art-direction">content variations
for increased clarity and focus</a> based on the client’s display size.
</p>
<p>
The proposed solutions are not mutually exclusive, and may work together
to address the complete set of <a href=
"http://usecases.responsiveimages.org/">use cases and requirements for
responsive images</a>.
</p>
<h2>
Conformance
</h2>
<p>
As well as sections marked as non-normative, all authoring guidelines,
diagrams, examples, and notes in this specification are non-normative.
Everything else in this specification is normative.
</p>
<p>
The key words <em class="rfc2119" title="must">must</em>, <em class=
"rfc2119" title="must not">must not</em>, <em class="rfc2119" title=
"required">required</em>, <em class="rfc2119" title="should">should</em>,
<em class="rfc2119" title="should not">should not</em>, <em class=
"rfc2119" title="recommended">recommended</em>, <em class="rfc2119"
title="may">may</em>, and <em class="rfc2119" title=
"optional">optional</em> in this specification are to be interpreted as
described in [<cite><a class="bibref" href=
"#bib-RFC2119">RFC2119</a></cite>].
</p>
<p>
This specification has the same <a href=
"http://dev.w3.org/html5/spec/single-page.html#conformance-requirements">conformance
requirements</a> and applies to the same <a href=
"http://dev.w3.org/html5/spec/single-page.html#conformance-classes">conformance
classes</a> as [<cite>HTML</cite>].
</p>
<p>
Implementations that use ECMAScript to expose the APIs defined in this
specification <em class="rfc2119" title="must">must</em> implement them
in a manner consistent with the ECMAScript Bindings defined in the
[<cite><a class="bibref" href="#bib-WEBIDL">WEBIDL</a></cite>]
specification.
</p>
<h2>
Definitions
</h2>
<p>
The following terms are used throughout this specification so they are
gathered here for the readers convenience. The following list of terms is
not exhaustive; other terms are defined throughout this specification.
</p>
<p>
The follow terms are defined by the [<cite>HTML</cite>] specification:
<dfn id="dfn-img-element"><a href=
"http://dev.w3.org/html5/spec/single-page.html#the-img-element"><code>img</code>
element</a></dfn>, <dfn id="dfn-source-element"><a href=
"http://dev.w3.org/html5/spec/single-page.html#the-source-element"><code>source</code>
element</a></dfn>, <dfn id="dfn-fallback-content"><a href=
"http://dev.w3.org/html5/spec/single-page.html#fallback-content">fallback
content</a></dfn>, and <dfn id="dfn-valid-media-query"><a href=
"http://dev.w3.org/html5/spec/single-page.html#valid-media-query">valid
media query</a></dfn>.
</p>
<h2>
The <code>picture</code> element
</h2>
<dl>
<dt>
<a href=
"http://dev.w3.org/html5/spec/single-page.html#element-dfn-categories"
title="element-dfn-categories">Categories</a>:
</dt>
<dd>
<a href=
"http://dev.w3.org/html5/spec/single-page.html#flow-content-1">Flow
content</a>.
</dd>
<dd>
<a href=
"http://dev.w3.org/html5/spec/single-page.html#phrasing-content-1">Phrasing
content</a>.
</dd>
<dd>
<a href=
"http://dev.w3.org/html5/spec/single-page.html#embedded-content-2">Embedded
content</a>.
</dd>
<dd>
<a href=
"http://dev.w3.org/html5/spec/single-page.html#palpable-content-0">Palpable
content</a>.
</dd>
<dt>
<a href=
"http://dev.w3.org/html5/spec/single-page.html#element-dfn-contexts"
title="element-dfn-contexts">Contexts in which this element can be
used</a>:
</dt>
<dd>
Where <a href=
"http://dev.w3.org/html5/spec/single-page.html#embedded-content-2">embedded
content</a> is expected.
</dd>
<dt>
<a href=
"http://dev.w3.org/html5/spec/single-page.html#element-dfn-content-model"
title="element-dfn-content-model">Content model</a>:
</dt>
<dd>
If zero descendents, then <a href=
"http://dev.w3.org/html5/spec/single-page.html#transparent">transparent</a>.
</dd>
<dd>
One or more <code>source</code> elements.
</dd>
<dd>
Zero or one <code>img</code> element, serving as <a href=
"#dfn-fallback-content" class="internalDFN">fallback content</a>.
</dd>
<dt>
<a href=
"http://dev.w3.org/html5/spec/single-page.html#element-dfn-attributes"
title="element-dfn-attributes">Content attributes</a>:
</dt>
<dd>
<a href=
"http://dev.w3.org/html5/spec/single-page.html#global-attributes">Global
attributes</a>
</dd>
<dd>
<code title="attr-picture-alt"><a href=
"#attr-picture-alt">alt</a></code>
</dd>
<dd>
<code title="attr-picture-src"><a href=
"#attr-picture-src">src</a></code>
</dd>
<dd>
<code title="attr-picture-srcset"><a href=
"#attr-picture-srcset">srcset</a></code>
</dd>
<dd>
<code title="attr-picture-crossorigin"><a href=
"#attr-picture-crossorigin">crossorigin</a></code>
</dd>
<dd>
<code title="attr-hyperlink-usemap"><a href=
"#attr-hyperlink-usemap">usemap</a></code>
</dd>
<dd>
<code title="attr-picture-ismap"><a href=
"#attr-picture-ismap">ismap</a></code>
</dd>
<dd>
<code>width</code>
</dd>
<dd>
<code>height</code>
</dd>
<dt>
<a href="http://dev.w3.org/html5/spec/single-page.html#element-dfn-dom"
title="element-dfn-dom">DOM interface</a>:
</dt>
<dd>
<pre>
[NamedConstructor=Picture,
NamedConstructor=Picture(unsigned long width),
NamedConstructor=Picture(unsigned long width, unsigned long height)]
HTMLPictureElement : HTMLImageElement{
attribute DOMString <a href="#dom-picture-alt" title=
"dom-picture-alt">alt</a>;
attribute DOMString <a href="#dom-picture-src" title=
"dom-picture-src">src</a>;
attribute DOMString <a href="#dom-picture-crossorigin" title=
"dom-picture-crossOrigin">crossOrigin</a>;
attribute DOMString <a href="#dom-picture-srcset" title=
"dom-picture-srcset">srcset</a>;
readonly attribute DOMString <span title=
"dom-picture-currentsrc">currentSrc</span>;
attribute DOMString <a href="#dom-picture-usemap" title=
"dom-picture-useMap">useMap</a>;
attribute boolean <a href="#dom-picture-ismap" title=
"dom-picture-isMap">isMap</a>;
readonly attribute DOMString media;
void <span title="dom-picture-load">load</span>();
}
</pre>
</dd>
</dl>
<p>
The <code><dfn id="dfn-picture">picture</dfn></code> element used for
displaying an image that can come from a range of sources (including the
<dfn id="attr-picture-src" title=
"attr-picture-src"><code>src</code></dfn> and <dfn id=
"attr-picture-srcset" title=
"attr-picture-srcset"><code>srcset</code></dfn> attributes). Which image
the user agent displays depends on the <a href=
"#dfn-algorithm-for-deriving-the-source-image" class=
"internalDFN">algorithm for deriving the source image</a>. The value of
the <dfn id="attr-picture-alt" title=
"attr-picture-alt"><code>alt</code></dfn> attribute provides equivalent
content for those who cannot process images or who have image loading
disabled.
</p>
<p>
The requirements on the <code title="attr-picture-alt"><a href=
"#attr-picture-alt">alt</a></code> attribute's value are described
<a href="http://www.w3.org/TR/html5/embedded-content-0.html#alt">in the
<code>img</code> section</a>.
</p>
<p>
The <code title="attr-picture-src"><a href=
"#attr-picture-src">src</a></code> attribute may be present, and if
present must contain a <a href=
"http://www.w3.org/TR/html5/infrastructure.html#valid-non-empty-url-potentially-surrounded-by-spaces">
valid non-empty URL potentially surrounded by spaces</a> referencing a
non-interactive, optionally animated, <dfn>image resource</dfn> that is
neither paged nor scripted.
</p>
<p class="note">
The requirements above imply that images can be static bitmaps (e.g.
PNGs, GIFs, JPEGs), single-page vector documents (single-page PDFs, XML
files with an SVG root element), animated bitmaps (APNGs, animated GIFs),
animated vector graphics (XML files with an SVG root element that use
declarative SMIL animation), and so forth. However, these definitions
preclude SVG files with script, multipage PDF files, interactive MNG
files, HTML documents, plain text documents, and so forth. <a href=
"http://www.w3.org/TR/html5/references.html#refsPNG">[PNG]</a> <a href=
"http://www.w3.org/TR/html5/references.html#refsGIF">[GIF]</a> <a href=
"http://www.w3.org/TR/html5/references.html#refsJPEG">[JPEG]</a> <a href=
"http://www.w3.org/TR/html5/references.html#refsPDF">[PDF]</a> <a href=
"http://www.w3.org/TR/html5/references.html#refsXML">[XML]</a> <a href=
"http://www.w3.org/TR/html5/references.html#refsAPNG">[APNG]</a>
<!-- <a href="#refsAGIF">[AGIF]</a> --> <a href=
"http://www.w3.org/TR/html5/references.html#refsSVG">[SVG]</a> <a href=
"http://www.w3.org/TR/html5/references.html#refsMNG">[MNG]</a>
</p>
<p>
The <code title="attr-picture-srcset"><a href=
"#attr-picture-srcset">srcset</a></code> attribute may be present, and if
present must conform to <a href="http://dev.w3.org/html5/srcset/">the
<code>srcset</code> specification</a>.
</p>
<dl class="domintro">
<dt>
<var>picture</var> . <code>currentSrc</code>
</dt>
<dd>
<p>
Returns the address of the current <span>image resource</span>.
</p>
<p>
Returns the empty string when there is no <span>image
resource</span>.
</p>
</dd>
</dl>
<div class="impl">
<p>
The <dfn title="dom-picture-currentSrc"><code>currentSrc</code></dfn>
IDL attribute is initially the empty string. Its value is changed by
the <span title="dfn-algorithm-for-deriving-the-source-image">resource
selection algorithm</span> defined below.
</p>
</div>
<p class="note">
There are three ways to specify an <span>image resource</span>, the
<code title="attr-picture-src">src</code> attribute, the <code title=
"attr-picture-srcset">srcset</code> attribute, or <code>source</code>
elements. The <code title="attr-picture-srcset">srcset</code> attribute
overrides both the <code title="attr-picture-src">src</code> attribute
and the elements; the <code title="attr-picture-src">src</code> attribute
overrides the elements.
</p>
<p>
The <dfn id="attr-picture-crossorigin" title=
"attr-picture-crossorigin"><code>crossorigin</code></dfn> attribute is a
<a href=
"http://www.w3.org/TR/html5/infrastructure.html#cors-settings-attribute">CORS
settings attribute</a>. Its purpose is to allow images from third-party
sites that allow cross-origin access to be used with <code><a href=
"http://www.w3.org/TR/html5/embedded-content-0.html#the-canvas-element">canvas</a></code>.
</p>
<p>
On getting the <code>media</code> IDL attribute, the user agent
<em class="rfc2119" title="must">must</em> return the media query that
matches the current environment.