forked from Wilto/draft-prop
-
Notifications
You must be signed in to change notification settings - Fork 35
/
index.html
505 lines (492 loc) · 27.3 KB
/
index.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
<!DOCTYPE html><meta charset="utf-8">
<meta content="width=device-width,initial-scale=1" name="viewport">
<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 href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet">
<!--[if lt IE 9]><script src='http://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]-->
<link class="ricg" href="http://www.w3.org/StyleSheets/TR/w3c-unofficial.css" rel="stylesheet">
</head>
<body>
<header><div class="head">
<p><a href="http://responsiveimages.org"><img alt="Responsive Images Community Group" src="https://raw.github.com/ResponsiveImagesCG/meta/master/logo/Web/RICG_logo_small.png" style="float:right"></a>
<a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
<h1>The picture element </h1>
<h2 class="no-num no-toc" id="an-html-extension-for-adaptive-images">An HTML extension for adaptive images</h2>
<h2 class="no-num no-toc ricg" id="living-document-last-updated-28-december-2012">Living document - Last updated 28 December 2012 </h2>
<dl>
<dt>This Version:</dt>
<dd class="ricg"><a href="http://picture.responsiveimages.org/">http://picture.responsiveimages.org/</a></dd>
<dt class="ricg">Latest W3C Published Version:</dt>
<dd><a href="http://www.w3.org/TR/html-picture-element/">http://www.w3.org/TR/html-picture-element/</a></dd>
<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 ricg">Copyright © 2012 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" id="abstract">Abstract</h2>
<p>The <code><a href="#dfn-picture">picture</a></code> element is an image container whose source content is determined by one or more CSS media queries.</p>
<h2 class="no-toc no-num" id="status">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 class="internalDFN" href="#dfn-open-issues">open issues</a>.</p>
</div>
</div>
<h2 class="no-num no-toc" id="table-of-contents">Table of Contents</h2>
<!--begin-toc-->
<ol class="toc">
<li><a href="#introduction"><span class="secno">1 </span>Introduction</a>
<ol class="toc">
<li><a href="#example-of-usage"><span class="secno">1.1 </span>Example of usage</a></li>
<li><a href="#differences-from-img-element"><span class="secno">1.2 </span>Differences from <code>img</code> element</a></ol></li>
<li><a href="#conformance"><span class="secno">2 </span>Conformance</a></li>
<li><a href="#definitions"><span class="secno">3 </span>Definitions</a></li>
<li><a href="#the-picture-element"><span class="secno">4 </span>The <code>picture</code> element</a></li>
<li><a href="#algorithm-for-deriving-the-source-image"><span class="secno">5 </span>Algorithm for deriving the source image</a></li>
<li><a class="no-num" href="#open-issues">Open Issues</a></li>
<li><a class="no-num" href="#acknowledgements">Acknowledgements</a></li>
<li><a class="no-num" href="#normative-references">Normative references</a></ol>
<!--end-toc-->
<h2 id="introduction"><span class="secno">1 </span>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><a href="#dfn-picture">picture</a></code> element to [<cite>HTML</cite>] that makes use of the <code> source</code> element. The <code><a href="#dfn-picture">picture</a></code> element remains backwards compatible with legacy user agents by degrading gracefully through <a class="internalDFN" href="#dfn-fallback-content">fallback content</a> (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><a href="#dfn-picture">picture</a></code> elements through ECMAScript.</p>
<h3 id="example-of-usage"><span class="secno">1.1 </span>Example of usage</h3>
<p><em>This section is non-normative.</em></p>
<p>This first sample shows how to combine the <code><a href="#dfn-picture">picture</a></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="">
<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><a href="#dfn-picture">picture</a></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="">
<p>Accessible text</p>
</picture></pre>
</div>
<h3 id="differences-from-img-element"><span class="secno">1.2 </span>Differences from <code>img</code> element</h3>
<p>Unlike the <code>img</code> element and its current <a href="http://dev.w3.org/html5/srcset/"><code>srcset</code> attribute</a>, the <code><a href="#dfn-picture">picture</a></code> element is intended to allow an author to reference many different image sources and associate those image sources with a CSS media query [<cite>CSS3-MEDIAQUERIES</cite>]. The <code>srcset</code> attribute of the <code>img</code> element only allows matching on display dimensions and pixel densities, and the user agent is not required to respect the author's declared desires. </p>
<p>The browser dynamically updates the displayed image based on the browsing environment. This means that the developer determines the most suitable image for the browsing environment. Or the most suitable image source may be a different version of an image that has been modified by the author to be suitable for a particular use. </p>
<h2 id="conformance"><span class="secno">2 </span>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 id="definitions"><span class="secno">3 </span>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 id="the-picture-element"><span class="secno">4 </span>The <code><a href="#dfn-picture">picture</a></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 class="internalDFN" href="#dfn-fallback-content">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>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{
readonly attribute DOMString media;
}</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 (see <code>srcset</code> attribute). Which image the user agent displays depends on the <a class="internalDFN" href="#dfn-algorithm-for-deriving-the-source-image">algorithm for deriving the source image</a>. </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. </p>
<p>It is <em class="rfc2119" title="recommended">recommended</em> that for cases where a single image source is available, and where no responsive adoption is needed, authors use the <code>img</code> element. Authors can use the srcset attribute for simple resized image sources.</p>
<p>The <span>chosen image</span> is the embedded content. </p>
<p>For user agents that don't support the <code><a href="#dfn-picture">picture</a></code> element, an author can provide an <code>img</code> element as <a class="internalDFN" href="#dfn-fallback-content">fallback content</a>. User agents that support the <code><a href="#dfn-picture">picture</a></code> element <em class="rfc2119" title="should not">should not</em> show this content to the user: it is intended for legacy user agents that do not support <code><a href="#dfn-picture">picture</a></code>, so that a legacy <code>img</code> element can be shown instead.</p>
<p>Authoring requirement: as with the <code>img</code> element, documents must not use the <code><a href="#dfn-picture">picture</a></code> element as a layout tool. In particular, picture elements should not be used to display transparent images, as they rarely convey meaning and rarely add anything useful to the document. </p>
<p>When used with the <code><a href="#dfn-picture">picture</a></code> element, a <span>document</span> <em class="rfc2119" title="should">should</em> only contain <code>source</code> elements need to represent the same subject matter, but cropping and zooming can differ.</p>
<div class="issue">
<div class="issue-title"><span>Issue 2</span></div>
<div class="">
<p>It should be codified that this is not a mechanism by which to swap disparate images depending on screen size. See bug <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=18384#c7">18384</a>.</p>
</div>
</div>
<h2 id="algorithm-for-deriving-the-source-image"><span class="secno">5 </span>Algorithm for deriving the source image</h2>
<p>The <dfn id="dfn-algorithm-for-deriving-the-source-image">algorithm for deriving the source image</dfn> as follows. The result is the image source to be used by the <code><a href="#dfn-picture">picture</a></code> element, which reflects the <code><a href="#dfn-picture">picture</a></code> element's <span><code>src</code> IDL attribute</span>: </p>
<div class="note">
<div class="note-title"><span>Note</span></div>
<div class="">
<p>What we want to do is have the <code><a href="#dfn-picture">picture</a></code> behave exactly the same as an <code>img</code> element, but with the only difference being that it is <code>source</code> elements is used to determine the value of the <code>src</code> IDL attribute (and hence what image content is displayed). How that is determined is through using the <code>media</code> attribute attribute of the <code>source</code> element. </p>
<p>So, to derive the <dfn id="dfn-source-image">source image</dfn>: ignoring any sources whose <code>type</code> is not supported by the browser, gather all the media queries from the <code>source</code> elements' <code>media</code> attributes into a "stylesheet", in document order. Any missing <code>media</code> attributes are just assumed to mean "all". Any media attributes that are not valid media queries are ignored. So, given the following: </p>
<pre><picture id="pictureElement">
<span class="example"> <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">
<!-- assume media all -->
<source srcset="small-1.jpg 1x, small-2.jpg 2x"></span>
<!-- the following are ignored -->
<span class="example"> <source media=" is the message " srcset="">
</span>
</picture></pre>
<p>Becomes the rough CSS equivalent of (a virtual stylesheet for the document?):</p>
<pre>//assume #pictureElement is magically scoped to the corresponding element.
@media all{
#pictureElement{
background-image: image-set(<span class="example">small-1.jpg 1x, small-2.jpg 2x</span>);
}
}
@media<span class="example"> all and (min-width: 45em)</span>{
#pictureElement{
background-image: image-set(<span class="example">large-1.jpg 1x, large-2.jpg 2x</span>);
}
}
@media <span class="example">all and </span><span class="example">(min-width: 18em)</span>{
#pictureElement{
background-image: image-set(<span class="example">med-1.jpg 1x, med-2.jpg 2x</span>);
}
}</pre>
<p>The API then just works the same as per images. Events are fired in the same way as if the image's src IDL attribute had been set manually by the author. </p>
<p>The resource fetching behavior of then governed by <cite>CSS Image Values and Replaced Content Module Level 4</cite>.</p>
</div>
</div>
<p>A user agent <em class="rfc2119" title="may">may</em> override requests for higher-resolution images based on user preferences. For example: “always request high-resolution images,” “always request low-resolution images,” and “request high-resolution images as bandwidth permits” based on the bandwidth information available to the browser.</p>
<h2 class="no-num" id="open-issues">Open Issues</h2>
<p>We are tracking <dfn id="dfn-open-issues">open issues</dfn> on Github. <a href="https://github.com/ResponsiveImagesCG/picture-element/issues">Please help close them</a>! </p>
<div id="open-issues-xhr">
</div>
<h2 class="no-toc no-num" id="reference-implementations">Reference implementations</h2>
<p>We have a list of <a href="https://github.com/Wilto/draft-prop/wiki/Current-users,-polyfills,-prototypes,-and-implementations">current users, polyfills, prototypes, and implementations</a> on Github. </p>
<h2 class="no-num" id="acknowledgements">Acknowledgements</h2>
<p id="participants">A <a href="http://www.w3.org/community/respimg/participants">complete list of participants</a> of the Responsive Images Community Group is available at the W3C Community Group Website.</p>
<h2 class="no-num" id="normative-references">Normative references</h2>
<dl class="bibliography">
<dt id="bib-CSS3-MEDIAQUERIES">[CSS3-MEDIAQUERIES]</dt>
<dd><a href="http://www.w3.org/TR/css3-mediaqueries/"><cite>Media Queries</cite></a>. (<a href="http://www.w3.org/TR/css3-mediaqueries/#status">status</a>).</dd>
<dt id="bib-HTML5">[HTML]</dt>
<dd><a href="http://dev.w3.org/html5/spec"><cite>HTML5.</cite></a> (<a href="http://dev.w3.org/html5/spec#status-of-this-document">status</a>).</dd>
<dt id="bib-RFC2119">[RFC2119]</dt>
<dd><a href="http://www.ietf.org/rfc/rfc2119.txt"><cite>Key words for use in RFCs to Indicate Requirement Levels.</cite></a></dd>
<dt id="bib-WEBIDL">[WEBIDL]</dt>
<dd><a href="http://www.w3.org/TR/WebIDL/"><cite>Web IDL.</cite></a> (<a href="http://www.w3.org/TR/WebIDL/#sotd">status</a>).</dd>
</dl>
<script class="ricg" src="https://raw.github.com/ResponsiveImagesCG/meta/master/scripts/show_issues.js"></script>
<script class="ricg" src="https://api.github.com/repos/ResponsiveImagesCG/picture-element/issues?state=open&callback=processResponse"></script>
<script class="ricg" src="https://raw.github.com/ResponsiveImagesCG/meta/master/scripts/ga.js"></script>