Prompt
I'm trying to set up AVIF fallback for older browsers
Latest observation
Oct 31, 2026
OpenAI APIWeb search: off
A good way to do AVIF fallback is to use the HTML <picture> element and provide sources in order of preference.
Example
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" alt="Description of the image">
</picture>
How it works
- Browsers that support AVIF load
image.avif - Browsers that don’t but support WebP load
image.webp - Older browsers fall back to the
<img>source, usually JPG or PNG
Notes
- Put the most modern format first
- Always include a normal
<img>fallback - Add a meaningful
altattribute - If you need responsive images, you can also use
srcsetandsizesinside<source>
Responsive example
<picture>
<source
type="image/avif"
srcset="image-480.avif 480w, image-800.avif 800w"
sizes="(max-width: 600px) 480px, 800px">
<source
type="image/webp"
srcset="image-480.webp 480w, image-800.webp 800w"
sizes="(max-width: 600px) 480px, 800px">
<img
src="image-800.jpg"
alt="Description of the image"
width="800"
height="600">
</picture>
If you want, I can also show you how to set this up in:
- plain HTML
- React / Next.js
- WordPress
- a build pipeline like Vite/Webpack