1001Ferramentas
📷 SEO

Srcset Pixel Density Analyzer

Reads an <img> srcset attribute and shows which assets are used for 1x, 2x and 3x across viewports.

Reading a srcset and understanding which image the browser picks

The attribute listing several versions of an image has two different grammars, and mixing them is the mistake that makes the optimisation stop working. With density descriptors you state how many physical pixels each file carries per CSS pixel — useful when the image has a fixed size. With width descriptors you state each file's real width in pixels, and the browser chooses based on the available space.

Paste the attribute contents and the page splits each entry, showing URL, descriptor and which of the two grammars is in play. It also warns when both appear together, which is invalid: the browser then ignores the whole attribute and falls back to the plain source, silently undoing all the work of generating the variants.

One detail almost everybody forgets: with width descriptors, the sizes attribute is mandatory. Without it the browser assumes the image spans the full viewport width and usually downloads a larger file than needed. It is the commonest explanation for a page that generated six variants and still pulls the biggest one on a phone.

Frequently asked questions

Which grammar should I use?
Width descriptors, in most cases: they let the browser weigh screen density and available space at once. Density descriptors only suit images with a fixed size in CSS pixels, such as an icon or a logo, where the space does not vary with the window.
What is the sizes attribute for?
To state how much space the image will occupy before CSS is applied — the browser has to choose the file early, before it knows the layout. It accepts media queries, letting you say the image takes half the width on a large screen and the full width on a phone.
Can I combine both grammars?
No. Mixing width and density descriptors in the same attribute makes it invalid, and the browser discards it entirely, falling back to the plain source. Since no error is visible, the page keeps working and nobody notices the optimisation has ceased to exist.

Related Tools