Developer tools

Picture Element Generator

Add image sources by format or media condition, set a fallback image, preview it live, and copy a complete responsive picture element.

Fallback image

How to use the picture element generator

  1. Add your sourcesList each format or media-specific image, most preferred first.
  2. Set the fallback imageProvide a src, meaningful alt text, and a loading strategy.
  3. Preview and copyCheck the live preview, then copy the finished picture markup.

How the picture element works

The browser scans source elements in order and uses the first one whose type is supported and whose media query matches, falling back to the img element if nothing else applies.

Order matters

List your most preferred formats, like AVIF then WebP, before more widely supported fallbacks.

Type attribute

Lets supporting browsers pick a modern, smaller image format automatically.

Media attribute

Serves an entirely different image, like a cropped mobile version, at different viewport widths.

Fallback img

Always required, and the only element that carries alt text for accessibility and non-supporting browsers.

Picture Element Generator FAQ

Why does source order matter in a picture element?

The browser uses the first matching source it finds, so list your most specific or most preferred formats and media conditions before more general fallbacks.

What is the fallback img for?

It's shown when no source element matches, and it's also what non-supporting browsers and screen readers rely on, so it always needs real alt text.

When should I use the type attribute on a source?

Use it to offer a modern format like AVIF or WebP as a source, letting supporting browsers choose it while others fall back to the img element.

When should I use the media attribute?

Use it to serve an entirely different image at different viewport widths, such as a cropped version for mobile versus a wide version for desktop.

Is my alt text applied to every source?

No, alt text only lives on the fallback img element, since that's the element the accessibility tree actually exposes.

Try other free tools

More handy tools from My Panda Toolbox.