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

Contenido del Curso

Introduction to HTML

Introduction to HTML

1. Basics Introduction
2. Basic Elements
3. Metadata and the Head Element
4. Advanced Text Formatting Elements
5. Advanced Concepts

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.

html

index

css

index

js

index

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.

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 5. Capítulo 5
We're sorry to hear that something went wrong. What happened?
some-alt