Skip to content

Commit 5d51266

Browse files
committed
Improve image slice examples, tie to image() notation so that there's a fallback story (meant to make this edit ages ago...)
1 parent 0825d04 commit 5d51266

2 files changed

Lines changed: 66 additions & 10 deletions

File tree

css3-images/Overview.html

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,19 +371,38 @@ <h3 id=url><span class=secno>4.1. </span> Image References and Image
371371

372372
<p>A portion of an image may be referenced (clipped out and used as a
373373
standalone image) by use of <a
374-
href="http://www.w3.org/TR/media-frags/#naming-space">fragment
374+
href="http://www.w3.org/TR/media-frags/#naming-space">media fragment
375375
identifiers</a>. <a href="#MEDIA-FRAGS"
376376
rel=biblioentry>[MEDIA-FRAGS]<!--{{!MEDIA-FRAGS}}--></a>
377377

378378
<div class=example>
379379
<p>For example,</p>
380380

381-
<pre>background-image: url('logos.png#xywh=10,30,60,20')</pre>
381+
<pre>background-image: url('sprites.png#xywh=10,30,60,20')</pre>
382382

383-
<p>uses the 60 pixel by 20 pixel rectangle of <code>logos.png</code>
383+
<p>uses the 60 pixel by 20 pixel rectangle of <code>sprites.png</code>
384384
beginning at the point 10 pixels in from the left, 30 pixels down from
385385
the top.
386386
</div>
387+
388+
<p class=note>Note however that a UA that doesn't understand the media
389+
fragments notation will display the entirety an image specified with
390+
&lsquo;<code class=css>url</code>&rsquo;. However, since URLs with media
391+
fragment identifiers can also be used in the &lsquo;<code
392+
class=css>image()</code>&rsquo; notation defined below, authors can take
393+
advantage of CSS's forward-compatible parsing rules to provide a fallback
394+
when using an image fragment URL:
395+
396+
<div class=example>
397+
<p>In the example below, the &lsquo;<code class=css>image()</code>&rsquo;
398+
notation is used together with the media fragment syntax, so that UAs
399+
that don't support media fragments fail to parse the second declaration
400+
and use the first.
401+
402+
<pre>
403+
<!-- -->background-image: url('swirl.png'); /* old UAs */
404+
<!-- -->background-image: image('sprites.png#xywh=10,30,60,20'); /* new UAs */</pre>
405+
</div>
387406
<!-- ====================================================================== -->
388407

389408
<h3 id=image-notation><span class=secno>4.2. </span> Image Annotations and
@@ -398,15 +417,26 @@ <h3 id=image-notation><span class=secno>4.2. </span> Image Annotations and
398417
that it can be automatically be reversed if used in text with a different
399418
directionality.
400419

420+
<p>So that authors can take advantage of CSS's forwards-compatible parsing
421+
rules to provide a fallback for image slices, implementations that support
422+
the &lsquo;<code class=css>image()</code>&rsquo; notation <em>must</em>
423+
support the <code>xywh=#,#,#,#</code> form of media fragment identifiers
424+
for images. <a href="#MEDIA-FRAGS"
425+
rel=biblioentry>[MEDIA-FRAGS]<!--{{!MEDIA-FRAGS}}--></a>
426+
427+
<p>The &lsquo;<code class=css>image()</code>&rsquo; notation is defined as:
428+
429+
401430
<pre class=prod><dfn id=ltimage-list>&lt;image-list></dfn> =
402431
image( [ &lt;image-decl> , ]* [ &lt;image-decl> | &lt;element-reference> | &lt;gradient> | &lt;color> ] )</pre>
403432

404433
<p>where &lt;image-decl> is given by:
405434

406435
<pre class=prod><dfn id=ltimage-decl>&lt;image-decl></dfn> =
407-
[ &lt;string> | &lt;url> ] [ snap? && &lt;resolution> ]? && [ ltr | rtl ]?
408-
409-
</pre>
436+
[ &lt;string> | &lt;url> ] [ snap? && &lt;resolution> ]? && [ ltr | rtl ]?</pre>
437+
438+
<p class=issue>Is there a point to allowing &lsquo;<code
439+
class=css>url()</code>&rsquo;?
410440

411441
<p>Each <a href="#ltimage-decl"><i>&lt;image-decl></i></a> represents an
412442
external image. If a &lt;string> is provided, it represents the same image

css3-images/Overview.src.html

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,34 @@ <h3 id="url">
179179

180180
<p>A portion of an image may be referenced (clipped out and used as a
181181
standalone image) by use of
182-
<a href="http://www.w3.org/TR/media-frags/#naming-space">fragment identifiers</a>.
182+
<a href="http://www.w3.org/TR/media-frags/#naming-space">media fragment identifiers</a>.
183183
[[!MEDIA-FRAGS]]
184184

185185
<div class="example">
186186
<p>For example,</p>
187187

188-
<pre>background-image: url('logos.png#xywh=10,30,60,20')</pre>
188+
<pre>background-image: url('sprites.png#xywh=10,30,60,20')</pre>
189189

190-
<p>uses the 60 pixel by 20 pixel rectangle of <code>logos.png</code> beginning
190+
<p>uses the 60 pixel by 20 pixel rectangle of <code>sprites.png</code> beginning
191191
at the point 10 pixels in from the left, 30 pixels down from the top.
192192
</div>
193+
194+
<p class="note">Note however that a UA that doesn't understand the media
195+
fragments notation will display the entirety an image specified with ''url''.
196+
However, since URLs with media fragment identifiers can also be used in the
197+
''image()'' notation defined below, authors can take advantage of CSS's
198+
forward-compatible parsing rules to provide a fallback when using an image
199+
fragment URL:
200+
201+
<div class="example">
202+
<p>In the example below, the ''image()'' notation is used together with
203+
the media fragment syntax, so that UAs that don't support media fragments
204+
fail to parse the second declaration and use the first.
205+
<pre>
206+
<!-- -->background-image: url('swirl.png'); /* old UAs */
207+
<!-- -->background-image: image('sprites.png#xywh=10,30,60,20'); /* new UAs */</pre>
208+
</div>
209+
</div>
193210

194211
<!-- ====================================================================== -->
195212

@@ -204,13 +221,22 @@ <h3 id="image-notation">
204221
declare the directionality of an image so that it can be automatically be
205222
reversed if used in text with a different directionality.</p>
206223

224+
<p>So that authors can take advantage of CSS's forwards-compatible parsing
225+
rules to provide a fallback for image slices, implementations that support
226+
the ''image()'' notation <em>must</em> support the <code>xywh=#,#,#,#</code>
227+
form of media fragment identifiers for images. [[!MEDIA-FRAGS]]
228+
229+
<p>The ''image()'' notation is defined as:
230+
207231
<pre class='prod'><dfn>&lt;image-list></dfn> =
208232
image( [ &lt;image-decl> , ]* [ &lt;image-decl> | &lt;element-reference> | &lt;gradient> | &lt;color> ] )</pre>
209233

210234
<p>where &lt;image-decl> is given by:</p>
211235

212236
<pre class='prod'><dfn>&lt;image-decl></dfn> =
213-
[ &lt;string> | &lt;url> ] [ snap? && &lt;resolution> ]? && [ ltr | rtl ]?
237+
[ &lt;string> | &lt;url> ] [ snap? && &lt;resolution> ]? && [ ltr | rtl ]?</pre>
238+
239+
<p class="issue">Is there a point to allowing ''url()''?
214240

215241
<p>Each <i>&lt;image-decl></i> represents an external image. If a &lt;string>
216242
is provided, it represents the same image that it would if the the string

0 commit comments

Comments
 (0)