Repository navigation
Description
As currently defined, the sizes attribute on img/source doesn't have any direct effect on the image; instead, it expresses a desired intrinsic width. You then combine it with sources having a w descriptor, describing how wide the source is in image pixels. Dividing sizes by w thus gives you an effective density, which lets you choose between sources. Finally, when you actually download the image, if, the w descriptor was telling the truth (the image actually is that wide in image pixels), applying the effective density to it results in an intrinsic size equal to what you said in sizes.
This is roundabout, but it works. But it hinges on the w descriptor telling the truth; if it lies, and the image is actually a different width in image pixels, when you apply the effective density you'll get a different size than what sizes says. Thus, you can't tell what the intrinsic width will actually be until you download the image, even tho in normal situations you have all the information you need right there in the markup.
This causes some bad interactions with the proposed intrinsicsize attribute. In most cases it directly provides the intrinsic width/height, but we want to respect the sizes attribute, as it's useful and powerful; so instead, when used on a sizes/w-using source, it just provides the intrinsic ratio.
The problem, then, is that even tho we can virtually always count on sizes giving us an intrinsic width, and intrinsicsize giving a ratio, thus giving us an intrinsic height, technically we have to wait until the image is downloaded to tell what the actual intrinsic width will be, thus negating the benefit of intrinsicsize.
I think we can make this change compatibly: any image that is using w correctly will experience no change, and any image that is using it incorrectly would have already had confusing sizing behavior, such that this has a good chance of actually improving things.
Activity
zcorpan commentedon Jun 28, 2023
intrinsicsizeis nowwidthandheightattributes mapping toaspect-ratio: auto w / h.zcorpan commentedon Oct 8, 2026
I used Claude to research the web compat impact with HTTP Archive and by emulating the change in a browser for 200 affected pages.
Out of the 200 sampled pages (mobile root pages from the 2026-09-01 crawl, emulated in headless Chromium 153 at a 360px viewport):
sizesasks for)The sample was 100 pages from the 11,215 the crawl data flagged as likely affected, and 100 from the 62,796 flagged as possibly affected. Extrapolating to all 14,605,919 mobile root pages, that's roughly 0.0008% broken, 0.005% worse, 0.0008% improved, and 0.05% changed in a neutral way. (With only 1 or 2 pages per verdict these are very rough.)
Details: https://github.com/zcorpan/sizes-compat-3981
The page that broke uses
srcset="icon@2x.png 2w" sizes="1px"to get the effect of2x, so the icons become 1×1. 48 mobile root pages do this with a wrongw. We could special-case a tiny source size like1pxto keep the current behavior and avoid regressing those pages. I'm not sure it's worth the extra complexity, though; it's only 48 pages out of the total 14,605,919 mobile root pages (~0.0003%).Since broken and worse pages together are roughly 0.006%, I think the post-load part of this change should be web compatible enough.