
{% endhighlight %}
---
layout: single
elementName: img
---
Defines an image inserted in the web page.
Example:
Copy
Example:
Copy
The URL where the image is hosted. You can use a relative URL. You can use an absolute URL. Alternative text to describe the image if it's not available. Used by screen readers. Describe the image as if it was not present. Defines a list of different sources for the same image. The browser will choose the best one to use. You can define a pixel density descriptor like The browser will either use You can use a width descriptor like Defines a list of different source sizes. You can combine each of them with a media query. The browser will use the Defines the height of the image. The height in pixels. Defines the width of the image. The width in pixels.
#
img

{% endhighlight %}
{% endhighlight %}
src
"/images/tiramisu.jpg"
"{{site.url}}/images/traffic.jpg"
alt
"Picture of a man standing in front of the Dragon's Pearl boat"
srcset
"/images/sunset-@2x.jpg 2x"
2x. In this case, sunset-@2x.jpg is 720px wide.
{% endhighlight %}
sunset.jpg or sunset-@2x.jpg depending on the space available, the pixel density, etc.
"/images/sunset-360.jpg 360w,
/images/sunset-720.jpg 720w,
/images/sunset-1440.jpg 1440w"
360w. This value is divided by one of the source sizes (defined in the sizes attribute) to obtain the pixel density.
{% endhighlight %}
sizes
"(min-width: 800px) 1440px, 720px"
1440px image (defined in srcset) if the viewport is larger than 800px.
It will use the 720px otherwise.
{% endhighlight %}
height
"240"
width
"120"