Conteúdo do Curso
Introduction to HTML
Introduction to HTML
Responsive Images
Responsive images in HTML are images that automatically adjust their size and resolution to fit the size of the device or viewport they are being displayed on. This is important because the size and resolution of devices can vary greatly, and using responsive images ensures that the images look clear and sharp on all devices.
The srcset
attribute allows you to specify multiple versions of an image at different resolutions, and the browser will automatically choose the appropriate version based on the viewport size.
index
index
index
In this example, three image versions are specified in the srcset
attribute: image-small.jpg
, image-medium.jpg
, and image-large.jpg
.
w
value indicates the width of each image in pixels;sizes
attribute specifies the image's width in different viewport sizes.
Note
Make sure multiple image versions are available at different resolutions. The
srcset
attribute only works with theimg
element and is not supported by older browsers. It is important to consider the performance of your website when using responsive images. Loading multiple versions of an image can increase the size of your web page and potentially impact the loading speed.
Obrigado pelo seu feedback!