HTML & CSS · Middle · Question 21 of 75

What are the srcset and sizes attributes on <img> for?

Explanation

srcset lists file variants (img-400.jpg 400w, img-800.jpg 800w), and sizes hints how wide the image will be in the layout ((max-width: 600px) 100vw, 50vw). The browser downloads the smallest sufficient file. To change cropping or format, use <picture>.

Further reading

Problem with a question

HTML & CSS · Middle · question 21

Test yourself

Take the HTML & CSS · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz