Source set attribute (srcset)

SVG is still the most preferred way to serve retina images to HiDPI devices because the file size is nearly always smaller than JPG and PNG, and you only need one image for both retina and non- retina devices. But there is another, very good option that's emerged, called srcset. This option isn't meant to replace SVG, but rather complement it, since SVG can't be used for traditional raster images and photos, which are more suited for JPEG and PNG.

Get Mastering CSS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.