How to use Img Tag's Attribute srcset

The srcset Attribute

The srcset attribute, allows us to specify a list of sources for an image, which will be delivered based on the pixel density or size of the user’s screen. So we can say that implementing the srcset attribute is a good way to provide to the browser a set of “suggestions” about the correct behavior it should have with a certain type of image. By doing so, we improve the loading of our page and the experience of our users.

Example: 

<img src="low-density-photo.jpg" srcset="small-photo.jpg 480w, big-photo.jpg 1024w" />


Comments

Popular posts from this blog

How to install and configure Alphabetic Pagination WordPress Plugin?

How to Add Google Web Fonts in WordPress Themes the “Right” way

How to check if it is WooCommerce page?