SiteTidy
Home /Tools /srcset Generator

srcset Generator

Easily create HTML image tags with responsive srcset attributes.

srcset Generator

Build responsive image tags with srcset and sizes.

Basic Attributes

Add loading="lazy"

Responsive Sources

Generated HTML

<text-blue-300">class="text-pink-400">img
  text-blue-300">src="image-800w.jpg"
  text-blue-300">srcset="
    image-400w.jpg 400w,
    image-800w.jpg 800w,
    image-1200w.jpg 1200w
  "
  text-blue-300">sizes="(max-width: 600px) 100vw, 50vw"
  text-blue-300">alt="A beautiful landscape"
  text-blue-300">loading="lazy"
/>

How srcset works

The srcset attribute provides a list of available image files and their sizes. The browser uses this list, along with the sizes attribute (which tells the browser how wide the image will be displayed on screen), to automatically download the most appropriate image for the user's screen size and resolution.

This prevents mobile users from downloading massive desktop-sized images, saving bandwidth and significantly improving page load speeds.

What is the srcset attribute?

The srcset attribute allows you to specify a list of image sources along with their intrinsic widths (e.g., 800w) or pixel density descriptors (e.g., 2x). This helps the browser intelligently choose the smallest possible image that still looks sharp on the user's display, drastically improving load times and saving bandwidth.

What is the sizes attribute?

When using width descriptors (like w), you must also include a sizes attribute. This attribute tells the browser what the displayed width of the image will be at various viewport breakpoints (e.g., (max-width: 600px) 100vw, 50vw), enabling the browser to select the optimal image from the srcset before it has even parsed your CSS.

Related Guides

Deepen your understanding with our expert articles.