HTML <img> tag

When writing in HTML, the <img> tag is an inline element used to designate a holding space for linked images. It is useful when you want to link pictures, diagrams, or illustrations to your web pages, either from your collection or another website. The following sections contain information about this tag, including an example of it in use, and related attributes and browser compatibility.
Example of <img> code
<img src="https://www.computerhope.com/chguy.gif" alt="Computer Hope guy" width="57" height="120"/>
Example result
Attributes
Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <img> tag, and a description of each.
Attribute | Description |
---|---|
alt | Designates the image's alternate text (required). |
crossorigin | Utilized to allow the use of <canvas> on images from third-party sites that permit cross-origin access. |
height | Designates the height of the image. |
ismap | Designates that an image is a server-side image map. |
usemap | Designates that an image is a client-side image map. |
src | Designates the URL of the linked image (required). |
width | Designates the width of the image. |
Deprecated attributes
A deprecated attribute is one that may function currently but is not supported in going forward. While the attribute may work with the current version of HTML, it will eventually be phased out. It is better to avoid using these attributes to help future-proof your website.
Attribute | Description |
---|---|
align | Designates the alignment of the image with respect to the content around it. |
border | Designates the width of the border surrounding the image. |
hspace | Designates the whitespace on right and left side of an image. |
longdesc | Designates additional information about the content. |
vspace | Designates the whitespace above and below an image. |
Compatibility
Edge | Internet Explorer | Firefox | Safari | Opera | Chrome |
---|---|---|---|---|---|
All versions | All versions | All versions | All version | All versions | All versions |
Browser, Client-side, Compatibility, HTML canvas tag, Image map, Server-side, Web design terms, Web page, Whitespace