Code · Made a little simpler

AVIF/WebP Fallback Markup Generator

Generate a picture element from an image URL and candidate widths. Set CDN query names or filename suffixes, optional sizes and intrinsic dimensions, then copy the escaped HTML.

Free to useNo account neededProcessed on your device
Your workspaceProcessed on your device

Undo: Ctrl/Cmd+Z · Redo: Ctrl/Cmd+Shift+Z or Ctrl+Y. Up to 20 steps and 4 million retained characters in this tab. Clear discards history.

Add this tool to your website

Paste this code into your page to add the tool and a visible ToolMellow credit link.

HTML embed code
Preview embed

AVIF/WebP Fallback Markup Generator: how to use it

  1. Enter the base image URL and planned widths. Choose query parameters for an image service or filename suffixes for separately hosted files.
  2. Choose the fallback format and preferred width. Add the image's alternative text, sizes and intrinsic dimensions as needed.
  3. Generate picture markup and review the selected fallback width. Copy or download the HTML and verify its candidate URLs in your deployment.

Limits and notes

Up to 32 distinct widths from 1 to 16,384 pixels and a base URL up to 2,048 characters. The markup uses the URL scheme and naming pattern you entered. Prepare and host matching assets or configure a compatible image service.

How your privacy works →

AVIF/WebP Fallback Markup Generator: common questions

Which image format appears first in the picture element?

The markup lists AVIF before WebP, then adds a JPG, JPEG or PNG img element. A browser selects a supported source and chooses a candidate width using the image layout and display conditions.

What if the preferred fallback width is missing from the list?

The generator picks the nearest listed width for img src. When two widths are equally close, it uses the smaller one.

Where should the class and alternative text go?

Both attributes go on img. Choose alternative text for the image's purpose and leave it empty if the image is decorative.

Guides