srcset lists candidate image widths, while sizes describes the expected display width. The browser uses those hints plus viewport and display density to choose a request, avoiding a large asset on a small display.
The demo changes viewport width and shows a matching candidate and byte count. Real selection also depends on density and cache state, so the example is illustrative.
When to use
Use it when the same image appears at different sizes or mobile image transfer is high.