HTML <img> tag

Updated: 09/12/2023 by Computer Hope
HTML img tag

When writing in HTML (hypertext markup language), the <img> tag is an inline element designates 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="" alt="Computer Hope guy" width="57" height="120"/>

Example result

Computer Hope guy


All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <img> tag has the following unique attributes.

Attribute Description
alt Designates the image's alternate text (required).
crossorigin Utilized for using <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 (uniform resource locator) of the linked image (required).
width Designates the width of the image.

Deprecated attributes

In addition to the above attributes, the <img> tag had the following deprecated attributes.

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.


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