×

html · level 3 · unit 1 · lesson 3

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

srcset offers the browser a choice of files.

Most phones and many laptops have a high : they squeeze two or three pixels into the space where older screens had one. A picture made for an older screen looks blurry on them.

srcset lists files for the browser to choose from. After each file name comes a : 1x for ordinary screens, 2x for screens with double the pixels. The browser downloads only the one that suits its screen.

Keep src as well. It is the : very old browsers ignore srcset and use src, so the picture still shows.

<h1>Pets looking for a home</h1>
<img src="dog.svg" srcset="dog.svg 1x, cat.svg 2x" alt="A pet looking for a new home" width="400" height="300">
<p>Ordinary screens get the first file. Sharper screens get the second.</p>

Press show my page to see it here.

Practice files are drawings, so each choice here is a different one and you can spot the swap. On a real site, every file shows the same photo.