Computerhelp4all logo Articles AboutTopicsQuizzesComputer Questions & AnswersComputer Terms & DefinitionsActivitiesContact

What Is The HTML <img> Tag?

What Is The HTML Img Tag

Date First Published: 1st March 2023

Topic: Web Design & Development

Subtopic: Web Development

Article Type: Computer Terms & Definitions

Difficulty: Medium

Difficulty Level: 5/10

Learn more about what the HTML <img> tag is in this article.

In HTML, the <img> tag is used to display an image in a document. When linking to an image, illustration, diagram, or vector, in a webpage, the <img> tag is used. When using this tag, images are not inserted into webpage. Instead, they are linked to webpages, either from the same website or another website. This basic HTML tag is supported by all major web browsers.

Note: Info Icon

To insert a hyperlink on images, place the <img> tag inside the <a> tag.


Note: Info Icon

Common image formats for the <img> tag that are supported by user agents include APNG, BMP, GIF, ICO, JPEG, PNG, SVG, Tiff, and WebP.

Example Of The <img< Tag

An example of the <img> tag can be seen below. It embeds an image file from Wikimedia onto this site.

<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Demystifying_Search_Engine_Optimization_-viz_notes-_-wcyvr_%288084222814%29.jpg/800px-Demystifying_Search_Engine_Optimization_-viz_notes-_-wcyvr_%288084222814%29.jpg" alt="Wikimedia SEO Image" style="width:90%">

Output:

Wikimedia SEO Image

Attributes

Below are the attributes for the <img> tag.

Attribute Description
Align Sets the alignment of the image in reference to elements surrounding it. Not supported in HTML5.
Alt Specifies the alternative text that will display when the image fails to load.
Border Sets the width of the border around the image. Not supported in HTML5.
Crossorigin Enables the use of <canva> on images from third-party sites that allow cross-origin access.
Height Sets the height of the image.
Hspace Defines spaces at the left and right sides of the image. Not supported in HTML5.
Ismap Specifies that the image is a server-side image map.
Longdesc Specifies the URL address with a detailed description of the image. Not supported in HTML5.
Usemap Specifies that the image is a client-side image map.
Src Specifies the URL of the image.
Vspace Defines spaces at the top and bottom of the image. Not supported in HTML5.
Width Sets the width of the image.


Feedback

  • Is there anything that you disagree with on this page?
  • Are there any spelling, grammatical, or punctuation errors on this page?
  • Are there any broken links or design errors on this page?

If so, it is important that you tell me as soon as possible on this page.


Comments