diff --git a/images/kettlebell.jpg b/images/kettlebell.jpg new file mode 100644 index 00000000000..e5e72207590 Binary files /dev/null and b/images/kettlebell.jpg differ diff --git a/images/wolf.jpg b/images/wolf.jpg new file mode 100644 index 00000000000..7848ec467f6 Binary files /dev/null and b/images/wolf.jpg differ diff --git a/source b/source index 0cb9b681ee1..b46faea063e 100644 --- a/source +++ b/source @@ -22916,8 +22916,8 @@ interface HTMLHyperlinkElementUtils { -

To embed an image in HTML, when there is only a single image resource, - use the img element and its src attribute.

+

To embed an image in HTML, when there is only a single image resource, use the img + element and its src attribute.

@@ -22928,8 +22928,8 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...
-

However, there are a number of situations for which the author might wish - to use multiple image resources that the user agent can choose from:

+

However, there are a number of situations for which the author might wish to use multiple image + resources that the user agent can choose from:

-

The above situations are not mutually exclusive. - For example, it is reasonable to combine different resources for different device-pixel-ratio - with different resources for art direction.

+

The above situations are not mutually exclusive. For example, it is reasonable to combine + different resources for different device-pixel-ratio with different resources for + art direction.

-

While it is possible to solve these problems using scripting, doing so introduces some other problems:

+

While it is possible to solve these problems using scripting, doing so introduces some other + problems:

-

With this in mind, this specification introduces a number of features to address the above problems in a declarative manner.

+

With this in mind, this specification introduces a number of features to address the above + problems in a declarative manner.

-
Device-pixel-ratio-based selection when the rendered size of the image is fixed
+
Device-pixel-ratio-based selection when the rendered size of the image is + fixed

The src and srcset - attributes on the img element can be used, - using the x descriptor, - to provide multiple images that only vary in their size - (the smaller image is a scaled-down version of the bigger image).

+ attributes on the img element can be used, using the x + descriptor, to provide multiple images that only vary in their size (the smaller image is a + scaled-down version of the bigger image).

-

The x descriptor is not appropriate when the - rendered size of the image depends on the viewport width (viewport-based selection), - but can be used together with art direction.

+

The x descriptor is not appropriate when the rendered + size of the image depends on the viewport width (viewport-based selection), but can + be used together with art direction.

@@ -23087,20 +23226,20 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ... <p><b><a href="/wiki/Marie_Lloyd">Marie Lloyd</a></b> (1870–1922) was an English <a href="/wiki/Music_hall">music hall</a> singer, ... -

The user agent can choose any of the given resources depending on - the user's screen's pixel density, zoom level, and possibly other factors such as the user's network conditions.

+

The user agent can choose any of the given resources depending on the user's screen's pixel + density, zoom level, and possibly other factors such as the user's network conditions.

-

For backwards compatibility with older user agents that - don't yet understand the srcset attribute, - one of the URLs is specified in the img element's src attribute. - This will result in something useful (though perhaps lower-resolution than the user would like) - being displayed even in older user agents. - For new user agents, the src attribute participates in the resource selection, - as if it was specified in srcset with a 1x descriptor.

+

For backwards compatibility with older user agents that don't yet understand the srcset attribute, one of the URLs is specified in the + img element's src attribute. This will result + in something useful (though perhaps lower-resolution than the user would like) being displayed + even in older user agents. For new user agents, the src + attribute participates in the resource selection, as if it was specified in srcset with a 1x descriptor.

-

The image's rendered size is given in the - width and height attributes, - which allows the user agent to allocate space for the image before it is downloaded.

+

The image's rendered size is given in the width and + height attributes, which allows the user agent to + allocate space for the image before it is downloaded.

@@ -23110,72 +23249,75 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...
-

The srcset and sizes attributes can be used, - using the w descriptor, - to provide multiple images that only vary in their size - (the smaller image is a scaled-down version of the bigger image).

+

The srcset and sizes attributes can be used, using the w + descriptor, to provide multiple images that only vary in their size (the smaller image is a + scaled-down version of the bigger image).

-

In this example, a banner image takes up the entire viewport width - (using appropriate CSS).

+

In this example, a banner image takes up the entire viewport width (using appropriate + CSS).

<h1><img sizes="100vw" srcset="wolf-400.jpg 400w, wolf-800.jpg 800w, wolf-1600.jpg 1600w"
      src="wolf-400.jpg" alt="The rad wolf"></h1>
-

The user agent will calculate the effective pixel density of each image - from the specified w descriptors and the specified rendered size in the sizes attribute. - It can then choose any of the given resources depending on - the user's screen's pixel density, zoom level, and possibly other factors such as the user's network conditions.

- -

If the user's screen is 320 CSS pixels wide, this is equivalent to specifying - wolf-400.jpg 1.25x, wolf-800.jpg 2.5x, wolf-1600.jpg 5x. - On the other hand, if the user's screen is 1200 CSS pixels wide, - this is equivalent to specifying - wolf-400.jpg 0.33x, wolf-800.jpg 0.67x, wolf-1600.jpg 1.33x. - By using the w descriptors and the sizes attribute, - the user agent can choose the correct image source to download regardless of how large the user's device is.

- -

For backwards compatibility, - one of the URLs is specified in the img element's src attribute. - In new user agents, the src attribute is ignored - when the srcset attribute uses w descriptors.

+

The user agent will calculate the effective pixel density of each image from the specified + w descriptors and the specified rendered size in the sizes attribute. It can then choose any of the given resources + depending on the user's screen's pixel density, zoom level, and possibly other factors such as + the user's network conditions.

+ +

If the user's screen is 320 CSS pixels wide, this is equivalent to specifying wolf-400.jpg 1.25x, wolf-800.jpg 2.5x, wolf-1600.jpg 5x. On the other hand, if + the user's screen is 1200 CSS pixels wide, this is equivalent to specifying wolf-400.jpg 0.33x, wolf-800.jpg 0.67x, wolf-1600.jpg 1.33x. By using the + w descriptors and the sizes + attribute, the user agent can choose the correct image source to download regardless of how + large the user's device is.

+ +

For backwards compatibility, one of the URLs is specified in the img element's + src attribute. In new user agents, the src attribute is ignored when the srcset attribute uses w descriptors.

-

In this example, the Web page has three layouts depending on the width of the viewport. - The narrow layout has one column of images (the width of each image is about 100%), - the middle layout has two columns of images (the width of each image is about 50%), - and the widest layout has three columns of images, and some page margin (the width of each image is about 33%). - It breaks between these layouts when the viewport is 30em wide and 50em wide, respectively.

+

In this example, the Web page has three layouts depending on the width of the viewport. The + narrow layout has one column of images (the width of each image is about 100%), the middle + layout has two columns of images (the width of each image is about 50%), and the widest layout + has three columns of images, and some page margin (the width of each image is about 33%). It + breaks between these layouts when the viewport is 30em wide and 50em wide, respectively.

<img sizes="(max-width: 30em) 100vw, (max-width: 50em) 50vw, calc(33vw - 100px)"
      srcset="swing-200.jpg 200w, swing-400.jpg 400w, swing-800.jpg 800w, swing-1600.jpg 1600w"
      src="swing-400.jpg" alt="Kettlebell Swing">
-

The sizes attribute sets up the - layout breakpoints at 30em and 50em, - and declares the image sizes between these breakpoints to be - 100vw, 50vw, or calc(33vw - 100px). - These sizes do not necessarily have to match up exactly with the actual image width as specified in the CSS.

- -

The user agent will pick a width from the sizes attribute, - using the first item with a <media-condition> (the part in parentheses) that evaluates to true, - or using the last item (calc(33vw - 100px)) if they all evaluate to false.

- -

For example, if the viewport width is 29em, - then (max-width: 30em) evaluates to true and 100vw is used, - so the image size, for the purpose of resource selection, is 29em. - If the viewport width is instead 32em, - then (max-width: 30em) evaluates to false, - but (max-width: 50em) evaluates to true and 50vw is used, - so the image size, for the purpose of resource selection, is 16em (half the viewport width). - Notice that the slightly wider viewport results in a smaller image because of the different layout.

- -

The user agent can then calculate the effective pixel density and choose an appropriate resource - similarly to the previous example.

+

The sizes attribute sets up the layout breakpoints at + 30em and 50em, and declares the image sizes + between these breakpoints to be 100vw, 50vw, or + calc(33vw - 100px). These sizes do not necessarily have to match up + exactly with the actual image width as specified in the CSS.

+ +

The user agent will pick a width from the sizes + attribute, using the first item with a <media-condition> (the part in + parentheses) that evaluates to true, or using the last item (calc(33vw - + 100px)) if they all evaluate to false.

+ +

For example, if the viewport width is 29em, then (max-width: 30em) evaluates to true and 100vw is used, + so the image size, for the purpose of resource selection, is 29em. If + the viewport width is instead 32em, then (max-width: + 30em) evaluates to false, but (max-width: 50em) evaluates to true + and 50vw is used, so the image size, for the purpose of resource + selection, is 16em (half the viewport width). Notice that the slightly + wider viewport results in a smaller image because of the different layout.

+ +

The user agent can then calculate the effective pixel density and choose an appropriate + resource similarly to the previous example.

@@ -23186,25 +23328,25 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...

The picture element and the source element, - together with the media attribute, - can be used, to provide multiple images that vary the image content - (for instance the smaller image might be a cropped version of the bigger image).

+ together with the media attribute, can be used, + to provide multiple images that vary the image content (for instance the smaller image might be + a cropped version of the bigger image).

<picture>
   <source media="(min-width: 45em)" srcset="large.jpg">
   <source media="(min-width: 32em)" srcset="med.jpg">
-  <img src="small.jpg" alt="The president giving an award.">
+  <img src="small.jpg" alt="The wolf runs through the snow.">
 </picture>
-

The user agent will choose the first source element - for which the media query in the media attribute matches, - and then choose an appropriate URL from its srcset attribute.

+

The user agent will choose the first source element for + which the media query in the media attribute + matches, and then choose an appropriate URL from its srcset attribute.

-

The rendered size of the image varies depending on which resource is chosen. - To specify dimensions that the user agent can use before having downloaded the image, - CSS can be used.

+

The rendered size of the image varies depending on which resource is chosen. To specify + dimensions that the user agent can use before having downloaded the image, CSS can be used.

img { width: 300px; height: 300px }
 @media (min-width: 32em) { img { width: 500px; height:300px } }
@@ -23214,9 +23356,9 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...
-

This example combines art direction- and device-pixel-ratio-based selection. - A banner that takes half the viewport is provided in two versions, - one for wide screens and one for narrow screens.

+

This example combines art direction- and device-pixel-ratio-based + selection. A banner that takes half the viewport is provided in two versions, one for wide + screens and one for narrow screens.

<h1>
  <picture>
@@ -23233,9 +23375,9 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...
-

The type attribute - on the source element can be used, - to provide multiple images in different formats.

+

The type attribute on the source element can be used, to provide multiple images in + different formats.

@@ -23248,14 +23390,12 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ... <p><b><a href="/wiki/Marie_Lloyd">Marie Lloyd</a></b> (1870–1922) was an English <a href="/wiki/Music_hall">music hall</a> singer, ... -

In this example, the user agent will choose the first source that has - a type attribute with a supported MIME type. - If the user agent supports WebP images, - the first source element will be chosen. - If not, but the user agent does support JPEG XR images, - the second source element will be chosen. - If neither of those formats are supported, - the img element will be chosen.

+

In this example, the user agent will choose the first source that has a type attribute with a supported MIME type. If the user + agent supports WebP images, the first source element will + be chosen. If not, but the user agent does support JPEG XR images, the second source element will be chosen. If neither of those formats are + supported, the img element will be chosen.

@@ -23287,8 +23427,9 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ... <figcaption>Barney Frank, 2011</figcaption> </figure> -

For details on what to put in the alt attribute, - see the Requirements for providing text to act as an alternative for images section.

+

For details on what to put in the alt + attribute, see the Requirements for providing text to act as an alternative for + images section.

The problem with this is that the user agent does not necessarily know what dimensions to use for the image when the image is loading. To avoid the layout having to be reflowed multiple times @@ -23324,13 +23465,13 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...


-

The img element is used with the src attribute, which gives the URL of the image to use for legacy user - agents that do not support the picture element. This leads - to a question of which image to provide in the src - attribute.

+

The img element is used with the src attribute, + which gives the URL of the image to use for legacy user agents that do not support the + picture element. This leads to a question of which image to provide in the src attribute.

-

If the author wants the biggest image in legacy user agents, the markup could be as follows:

+

If the author wants the biggest image in legacy user agents, the markup could be as + follows:

<picture>
  <source srcset="pear-mobile.jpeg" media="(max-width: 720px)">
@@ -23363,9 +23504,9 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...

-

Above the max-width media feature is used, giving the maximum - (viewport) dimensions that an image is intended for. - It is also possible to use min-width instead.

+

Above the max-width media feature is used, giving the maximum (viewport) + dimensions that an image is intended for. It is also possible to use min-width instead.

<picture>
  <source srcset="pear-desktop.jpeg" media="(min-width: 1281px)">
@@ -118417,6 +118558,18 @@ INSERT INTERFACES HERE
   
   
 
+  
+

The image of the wolf in the embedded content introduction is based on a photo + by Barry O'Neill. + (Public domain) +

+ +
+

The image of the kettlebell swing in the embedded content introduction is based on a photo + by kokkarina. + (CC0 1.0) +

+

The image of two cute kittens in a basket used in the context menu example is based on a photo