Date First Published: 1st March 2023
Topic: Web Design & Development
Subtopic: Web Development
Article Type: Computer Terms & Definitions
Difficulty: MediumDifficulty 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.
To insert a hyperlink on images, place the <img> tag inside the <a> tag.
Common image formats for the <img> tag that are supported by user agents include APNG, BMP, GIF, ICO, JPEG, PNG, SVG, Tiff, and WebP.
An example of the <img> tag can be seen below. It embeds an image file from Wikimedia onto this site.
Output:
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. |
If so, it is important that you tell me as soon as possible on this page.
Network Services Network Setups Network Standards Network Hardware Network Identifiers Network Software Internet Protocols Internet Organisations Data Transmission Technologies Web Development Web Design Web Advertising Web Applications Web Organisations Web Technologies Web Services SEO Threats To Systems, Data & Information Security Mechanisms & Technologies Computer Hardware Computer Software Ethics & Sustainability Legislation & User Data Protection