img tag, or Image Embed element, embeds an image in an HTML document.
There are two attributes that are required for the
src, which provides the URL of the image, and
alt, which provides an alternate text for the image. Alt text is displayed if the image cannot be displayed for some reason. It is also read by screen readers and machines for SEO purposes.
<img src="path-to-image.jpg" alt="aletrnate description of the image" width="600" height="400">
Provides alternate, descriptive text for the image.
Allows images that are embedded from third-party sites to be used with canvas. Values:
Provides the height of the image in pixels.
Designates that the image is a server-side image map.
Utilizing the values
loading attribute determines if the browser should load the
<img> immediately or after certain conditions are met.
Provides the URL that has a detailed description of the image.
Determines which referrer information is sent when fetching the
<img>. Possible values:
Provides image sizes for different page layouts.
Provides the URL for the image.
Provides a list of image files which will be used in different situations, such as different browser sizes.
Designates that the image is a client-side image map.
Provides the width of the image in pixels.
Have a code example of
<img>? Submit a codepen.io demo and we'll showcase it here ↴
Help @reference spread the word by sharing this article on Twitter...Tweet This