HTML img Tag

The HTML <img> tag is used to add images into an HTML Images are not directly inserted into web pages. Images are linked to web pages and it creates a holding space for the image.

These two attributes are very important in the <img> tag src attribute this attribute is used to define the source of the image and the alt attribute with this attribute can define the alternative text of the image.


<img src="URL" alt="alternate text">


<!DOCTYPE html>
      <title>HTML IMG tag</title>
      <h2>HTML IMG tag example</h2>
      <img src="" alt="A beautiful flower" width="350" height="250">


HTML img tag


Attribute Value Description
alt text It is used to define an alternative text for the image.
crossorigin anonymous
It is used to embed images from third-party sites that allow cross-origin access to be used with canvas.
height pixel defines the height of an image.
ismap ismap It is used to specify an image as a server-side image map.
longdesc URL is used to define the long description of an image.
referrerpolicy no-referrer
is used to specify which referrer information to use when fetching an image.
size sizes it is used to define the image sizes for a different layout.
srcset URL-list It is used to define a list of image files to use in different situations.
usemap #mapname It is used to specify an image as a client-side image map .
width pixel defines the width of an image.

Global Attributes

The <img> tag supports the Global Attributes in HTML.

Event Attributes

The <img> tag supports the Event Attributes in HTML.

Supported Browsers

Element Chrome Firefox IE Opera Safari
<img> Yes Yes Yes Yes Yes

Leave a Comment

Your email address will not be published.