Reputation: 181
Digital Ocean suggests the following format for webp images:
<picture>
<source srcset="logo.webp" type="image/webp">
<img src="logo.png" alt="Site Logo">
</picture>
In the example below I have applied a class to the jpg. Is it a good idea (or necessary) to apply the same class to the webp? How about adding the alt tag? Do webp images need an alt tag?
<picture>
<source srcset="images/pic.webp" type="image/webp">
<img src="images/pic.jpg" class="img-fluid" alt="">
</picture>
Upvotes: -1
Views: 285
Reputation: 3237
I assume you are referring to this article.
While it's certainly possible to use the picture and source elements, there are reasons against it:
The alternative option is to use Apache’s mod_rewrite module to automate the process of serving .webp images to supporting browsers (also in the article). The advantages being:
Upvotes: 1