HTML Intro

HTML Intro Quiz

HTML Intro Exercise

HTML Basics

HTML Basic Quiz

HTML Basic Exercise

HTML Advance

HTML Advance Quiz

HTML Advance Exercise

HTML Tags List

HTML Global Attributes

HTML Attributes


HTML img Tag

HTML img Tag



The img tag is used to embed an image in an HTML page. We can only link images inside the HTML document. We cannot insert images into it. The img tag specifies the space for the image in the document. It has two required attributes for best performance. Thes are:-

  1. src:-  Specifies the path to the image
  2. alt:- Specifies an alternate text for the image in case the image does not appear

We have to specify width and height of an image otherwise page flickers when loads. For image linking, we have to add img tag in it.


Attribute Explanation:-


Attribute Value Description
alt text Specifies alternate text for image.
crossorigin anonymous
Allow images from third-party sites that allow cross-origin access to be used with canvas.
height pixels Specifies height of an image.
ismap ismap Specifies image as a server-side image map.
loading eager
Specifies whether browser should load an image immediately or to defer loading of images until some conditions are met.
longdesc URL Specifies URL to a detailed description of image.
referrerpolicy no-referrer
Specifies which referrer information to use when fetching an image.
sizes sizes Specifies image sizes for different page layouts.
src URL Specifies path to the image.
srcset URL-list Specifies list of image files to use in different situations.
usemap #mapname Specifies image as a client-side image map.
width pixels Specifies width of an image.




Its syntax is:- < img >

Code Explanation

All Tutorials related to HTML Tags List

All Sections related to HTML