Are you ready?
10 questions to solve
- This quiz goes to full-screen once you press the Start button.
- At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
srcset
attribute is set on an <img>
, it's invalid to have the src
attribute. True or false?src
even when an <img>
has srcset
, for the sake of supporting browsers that don't understand srcset
. For more info, refer to HTML Images — The srcset
Attribute.srcset
matter?srcset
. For more info, refer to HTML Images — The srcset
Attribute: What is srcset
?x
descriptor in the srcset
attribute?x
stands for the density descriptor. This goes with choice (C). For more info, refer to HTML Images — The srcset
Attribute: Pixel density and the x
descriptor.Suppose we want to set up an <img>
element to serve either of the following two images depending on the DPR of the underlying device:
- cats-1x.jpg for a DPR of 1
- cats-2x.jpg for a DPR of 2
,
). This goes with choice (C). For more info, refer to HTML Images — The srcset
Attribute: Pixel density and the x
descriptor.srcset
attribute?w
), paired with the actual width, has the following general form: <int>w
, where <int>
represents an integer. This goes with choice (A). For more info, refer to HTML Images — The srcset
Attribute: Different widths and the w
descriptor.srcset
, we must always specify more than one image source. True or false?srcset
. For more info, refer to HTML Images — The srcset
Attribute: What is srcset
?srcset
for the first image source, we must use a width descriptor for all the rest of the sources. True or false?srcset
attribute — either x
or w
, NOT both.srcset
? Width descriptor or density descriptor?srcset
Attribute: Different widths and the w
descriptor.srcset
is a must-to-have on an <img>
element when using width descriptors?The sizes
attribute is required when we have an <img>
with a srcset
attribute containing width descriptors. This is because the width descriptors specify the intrinsic widths of all the given image sources, while sizes
specifies the widths of the corresponding slots. Hence, the correct choice is (B).
For more info, refer to HTML Images — The srcset
Attribute: Different widths and the w
descriptor.
Bob wrote the following HTML to serve cats.png when the width of the viewport is larger than 600px and serve dogs.png (a completely different image) otherwise.
<img sizes="(max-width: 600px) 600px, 100vw" srcset="cats.png 600w, dogs.png 600w">
Two important things to note:
- The actual width of both the images is the same.
- The DPR of the underlying device shouldn't affect the chosen image.
What Bob is trying to achieve here is something close to art direction which isn't the job of srcset
. In other words, srcset
isn't meant to switch between completely different images. Hence, choice (D) is correct.
Apart from this, on the technical side, the width descriptor can't appear more than once in the srcset
attribute. This means that choice (C) is also correct.
For more info, refer to HTML Images — The srcset
Attribute: Different widths and the w
descriptor.