Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Responsive Images | Advanced Concepts
Introduction to HTML

bookResponsive 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.html

index.html

copy

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 the img 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.

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 5. Chapitre 5

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Suggested prompts:

Posez-moi des questions sur ce sujet

Résumer ce chapitre

Afficher des exemples du monde réel

Awesome!

Completion rate improved to 3.45

bookResponsive Images

Glissez pour afficher le menu

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.html

index.html

copy

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 the img 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.

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 5. Chapitre 5
some-alt