Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML img loading attribute

HTML The loading attribute

HTML img Tag Reference HTML tag

Example

Add lazy loading to several images at the bottom of the page, so they only appear when the mouse scrolls to their location:

<img src="/images/wedding.jpeg" alt="Wedding" style="width:100%">
<img src="/images/rocks.jpeg" alt="Rocks" style="width:100%">
<img src="/images/paris.jpeg" alt="Paris" style="width:100%" loading="lazy">
<img src="/images/nature.jpeg" alt="Nature" style="width:100%" loading="lazy">
<img src="/images/underwater.jpeg" alt="Underwater" style="width:100%" loading="lazy">
<img src="/images/ocean.jpeg" alt="Ocean" style="width:100%" loading="lazy">
<img src="/images/mountainskies.jpeg" alt="Mountains" style="width:100%" loading="lazy">

Try it »


Browser support

property
loading 77.0 79.0 75.0 Not Supported 64.0

Definition and Usage

The loading attribute specifies whether the browser should load the image immediately or defer loading it.

Setting loading="lazy" makes the image appear only when the mouse scrolls to its location.


Syntax



Attribute values

Value Description
eager By default, images load immediately.
lazy The image is loaded lazily and only appears when the mouse scrolls to its location.

HTML img Tag Reference HTML tag