×

Html & Html5

The World's best Software Development Study Portal

HTML image tag


It is used to display image on the web page. HTML img tag is an empty tag that contains attributes only, closing tags are not used in HTML image tag. Src attribute is used with image tag to provide the path for image to be displayed. It is used as below:


Let's understand this by the following example:


Output:


 imalayas


Some of the other attributes of img tag are:

  1. alt
  2. width
  3. height

alt attribute

It is used to show alternate text if image is not displayed.The value of alt attribute should describe the image. It is used as below:


Let's understand this by the following example:


Output:


Himalayas


Width and Height attribute

Width attribute is used to set the width of an image. Height attribute used to set the height of an image.It is used as below:


Let's understand this by the following example:


Output: