如何在HTML中使用Webp图像格式 [英] How to use webp image format in HTML

查看:838
本文介绍了如何在HTML中使用Webp图像格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是图像的一种新格式,但我不知道如何以HTML格式显示。

I know this is a new format for images, but I don't know how to show it in HTML.

有人知道我能做到这一点吗?哪些浏览器可以显示除chrome之外的这种图像格式?

Does anyone know how I can do that? Which browsers can show this image format besides chrome?

sample-webp-image.webp

推荐答案

您可以像使用任何图像一样使用webp:

You use webp like any image:

<img src="img.webp" />

但是,由于并非始终受支持(请参见 http://caniuse.com/#feat=webp ),您可以使用它来设置后备广告:

However since it's not always supported (see http://caniuse.com/#feat=webp), you can use this to set a fallback:

<picture>
  <source srcset="img.webp" type="image/webp">
  <source srcset="img.jpg" type="image/jpeg"> 
  <img src="img.jpg">
</picture>

这篇关于如何在HTML中使用Webp图像格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆