This is currently not supported with CSS.
In the CSS Images Module Level 4 Draft, a fallback solution is suggested, but this is currently not supported anywhere. (2.4. Image Fallbacks and Annotations: the image() notation)
But if it will become part of a standard in some years, you then might be able to write:
.home-banner-background {
image:image('img/banner.webp', 'img/banner.jpg')
}
Until then you need to use tools like Modernizer, as suggested in the answer of Fifi
Alternatively, the picture
HTML tag might something you could think of, but if that is usable in your case depends on how the image should resize on your site:
<picture>
<source srcset="img/banner.webp" type="image/webp">
<source srcset="img/banner.jpg" type="image/jpeg">
<img src="img/banner.jpg">
</picture>
@supports (property: value){/*rules*/}
-- not image file format support. It would be nice to be able to do@supports (background-image: url('existing-image.webp')){/*...*/}
but for quite obvious reasons this doesn't work. – Helicopter@media
and@supports
representif
structures. – Periodic