Hi all,
I ran into an interesting challenge this morning while working on a multilingual greeting card web app: we have assets like immagini buongiorno frizzante that need to be displayed both responsively and accessibly across desktop and mobile views.
I’ve been experimenting with the <picture> element and srcset to serve different resolutions depending on the viewport, and so far it seems to work well:
A couple of questions I’m hoping the community can help with:
Performance: Are there recommended tools or build pipeline steps you use to automatically generate optimized variants of images like these (WebP/AVIF + fallback JPG/PNG)?
Accessibility: For creative imagery that’s basically a “good morning” greeting, do you prefer a descriptive alt text like above or something more minimal?
CSS handling: If you’re handling similar assets with frameworks (Tailwind, Bootstrap, etc.), has anyone found good patterns for responsive spacing/scaling without hard-coding sizes?
Your approach with picture and srcset is solid and widely used. That is the right direction for responsive images today.
For performance, many teams use build tools like ImageMagick or Sharp in the build process to generate WebP and AVIF versions automatically. Most modern bundlers support this through plugins, so images stay optimized without manual work.
For accessibility, descriptive alt text is usually better when the image carries meaning, like a greeting. If the text in the image matters to the user, describe it clearly. If it is purely decorative, an empty alt attribute is fine.
On the CSS side, letting the image be fluid works best. Use max width one hundred percent and height auto. Utility frameworks handle this well without fixed sizes. Container based sizing usually scales better than viewport based rules.
With the ever increasing band width of cellular networks, conditional downloading of images is getting less and less important. Unless I’m making a site with huge numbers of unique visitors or it concerns a very large image, I’ll just optimize an image for the web and leave it at that. So, I’m generally using one-size-fits-all images. Just do a rendering speed benchmark and see for yourself that the differences when using conditional downloads are minute to almost non-existent.
For the build pipeline, I’ve had good results using Sharp in a Node script to auto-generate the AVIF and WebP variants. It’s much faster than doing it through a GUI. Regarding the CSS spacing, I usually avoid hard-coding by using aspect-ratio in the CSS. It prevents layout shift while the image loads, which is huge for Core Web Vitals. If you’re using Bootstrap, the .img-fluid class is okay, but combining it with a container that has a clamped width based on rem units tends to scale more naturally across weird viewport sizes.