Skip to content

Commit d3a4005

Browse files
committed
Expanded the <resolution> section to actually talk about what the unit means.
1 parent 4dc5f67 commit d3a4005

2 files changed

Lines changed: 65 additions & 29 deletions

File tree

css3-images/Overview.html

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,37 @@ <h2 id=resolution-units><span class=secno>3. </span> Resolution Units: the
342342
<dd>dots per &lsquo;<code class=css>px</code>&rsquo; unit
343343
</dl>
344344

345-
<p class=note>The default resolution of raster images in CSS is
346-
&lsquo;<code class=css>1dppx</code>&rsquo;.</p>
345+
<p>The &lt;resolution> unit represents the size of a single "dot" of an
346+
image. For raster images, a dot is an image pixel. For vector images, a
347+
dot is a pixel in the outermost coordinate space of the image. A
348+
&lt;resolution> defines how many of these dots fit in a CSS &lsquo;<code
349+
class=property>in</code>&rsquo;, &lsquo;<code
350+
class=property>cm</code>&rsquo;, or &lsquo;<code
351+
class=property>px</code>&rsquo; so that images can be sized accordingly.
352+
<span class=note>The default resolution of raster images in CSS is
353+
&lsquo;<code class=css>1dppx</code>&rsquo;, which is equivalent to
354+
&lsquo;<code class=css>96dpi</code>&rsquo;.</span>
355+
356+
<div class=example>
357+
<p>Printers tend to have substantially higher resolution than computer
358+
monitors; due to this, an image that looks fine on the screen may look
359+
pixellated when printed out. A &lt;resolution> may be used in the
360+
&lsquo;<a href="#image-resolution0"><code
361+
class=property>image-resolution</code></a>&rsquo; property to embed a
362+
high-resolution image into the document that maintains an appropriate
363+
size, ensuring attractive display both on screen and on paper:</p>
364+
365+
<pre class=css><code>
366+
img.high-res {
367+
image-resolution: 300dpi;
368+
}</code></pre>
369+
370+
<p>With this set, an image meant to be 5 inches wide that was saved at
371+
300dpi will actually display as 5 inches wide; without this set, the
372+
image would display as approximately 15.6 inches wide since the image is
373+
15000 image pixels across, and by default there are 96 image pixels per
374+
inch.</p>
375+
</div>
347376
<!-- ====================================================================== -->
348377

349378
<h2 id=image><span class=secno>4. </span> Image Values: the &lt;image>
@@ -463,7 +492,7 @@ <h3 id=image-notation><span class=secno>4.2. </span> Image Annotations and
463492
<p>If a directional keyword (&lsquo;<code class=css>ltr</code>&rsquo; or
464493
&lsquo;<code class=css>rtl</code>&rsquo;) is given, the image itself gains
465494
that directionality. If the image is used in a property on an element with
466-
opposite directionality, it must be mirrored in the inline dimension when
495+
opposite directionality, is must be mirrored in the inline dimension when
467496
rendered.
468497

469498
<p>Multiple arguments can be given separated by commas, in which case the
@@ -514,8 +543,8 @@ <h3 id=element-reference><span class=secno>4.3. </span> Using Elements as
514543
slide in a slideshow. The syntax for &lsquo;<code
515544
class=css>element()</code>&rsquo; is defined as:
516545

517-
<pre class=prod><dfn id=ltelement-reference>&lt;element-reference></dfn> =
518-
element( [&lt;id-selector> | &lt;identifier> ] )</pre>
546+
<pre
547+
class=prod><dfn id=ltelement-reference>&lt;element-reference></dfn> = element( [&lt;id-selector> | &lt;identifier> ] )</pre>
519548

520549
<p>where &lt;id-selector> is an ID selector <a href="#SELECT"
521550
rel=biblioentry>[SELECT]<!--{{!SELECT}}--></a>, and &lt;identifier> is an
@@ -540,14 +569,14 @@ <h3 id=element-reference><span class=secno>4.3. </span> Using Elements as
540569

541570
<p>If the &lsquo;<code class=css>element()</code>&rsquo; function refers to
542571
an element, then it represents an image with width and height equal to the
543-
width and height of the bounding box of the border boxes of the referenced
544-
element. The image must be constructed by rendering the referenced element
545-
and its descendants at the same size that the element would be in its
546-
document, over an infinite transparent black background, positioned so
547-
that the edges of the margin box of the element is flush with the edges of
548-
the image. <span class=note>If the element has decorations or descendants
549-
that extend outside the margin box, these will be clipped to the margin
550-
box in the generated image by default. &lsquo;<code
572+
width and height of the margin box of the referenced element. The image
573+
must be constructed by rendering the referenced element and its
574+
descendants at the same size that the element would be in its document,
575+
over an infinite transparent black background, positioned so that the
576+
edges of the margin box of the element is flush with the edges of the
577+
image. <span class=note>If the element has decorations or descendants that
578+
extend outside the margin box, these will be clipped to the margin box in
579+
the generated image by default. &lsquo;<code
551580
class=css>background-repeat:extend</code>&rsquo; may allow the author to
552581
override this behavior so that decorations and descendants outside the
553582
margin box are still painted.</span> If the referenced element or an
@@ -566,22 +595,7 @@ <h3 id=element-reference><span class=secno>4.3. </span> Using Elements as
566595
regeneration process. That is, the image must look identical to the
567596
referenced element, modulo rasterization quality.
568597

569-
<p class=note>While the decision is up to the host language, it is intended
570-
that element() can validly refer to some types of elements that are
571-
associated with the document but not descendants of the root element. For
572-
example, in HTML the &lt;img>, &lt;video>, and &lt;canvas> elements all
573-
have a reasonable notion of what it means to "be rendered" without being
574-
part of a document, and so they can be created with Javascript, associated
575-
with a <a href="#css-element-reference-identifier"><i>CSS Element
576-
Reference Identifier</i></a>, and used in element() without being appended
577-
to the document.
578-
579598
<div class=example> TODO: copy an example from the MozHacks article</div>
580-
581-
<p class=issue>Moz's implementation allows directly referencing SVG paint
582-
servers. This doesn't come for free - do we want to spec it out? I want to
583-
be able to use SVG paint servers *somehow*. I'm not sure if this is quite
584-
the place to do it, though.</p>
585599
<!-- ====================================================================== -->
586600

587601
<h4 class="no-num no-toc" id=element-cycles> Detecting and Resolving

css3-images/Overview.src.html

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,29 @@ <h2 id='resolution-units'>
149149
<dd>dots per ''px'' unit</dd>
150150
</dl>
151151

152-
<p class="note">The default resolution of raster images in CSS is ''1dppx''.</p>
152+
<p>The &lt;resolution> unit represents the size of a single "dot" of an image. For raster images,
153+
a dot is an image pixel. For vector images, a dot is a pixel in the outermost coordinate space of
154+
the image. A &lt;resolution> defines how many of these dots fit in a CSS 'in', 'cm', or 'px' so that
155+
images can be sized accordingly. <span class='note'>The default resolution of raster images in
156+
CSS is ''1dppx'', which is equivalent to ''96dpi''.</span></p>
157+
158+
<div class='example'>
159+
<p>Printers tend to have substantially higher resolution than computer monitors; due to this,
160+
an image that looks fine on the screen may look pixellated when printed out. A
161+
&lt;resolution> may be used in the 'image-resolution' property to embed a high-resolution
162+
image into the document that maintains an appropriate size, ensuring attractive display
163+
both on screen and on paper:</p>
164+
165+
<pre class='css'><code>
166+
img.high-res {
167+
image-resolution: 300dpi;
168+
}</code></pre>
169+
170+
<p>With this set, an image meant to be 5 inches wide that was saved at 300dpi will actually
171+
display as 5 inches wide; without this set, the image would display as approximately 15.6 inches
172+
wide since the image is 15000 image pixels across, and by default there are 96 image pixels per
173+
inch.</p>
174+
</div>
153175

154176
<!-- ====================================================================== -->
155177

0 commit comments

Comments
 (0)