<img> tag in HTML
The <img> tag is used to defines an image in an HTML document. Learn more about <img> tag Visit Here.
Important Description
- The <img> tag has no end tag in HTML, and does not need a closing tag.
- But <img> tag must be properly closed in XHTML, it's look like <img />.
- In the <img> tag, must have to defined src attribute.
Example of <img> tag
Result Look Like
<img> Tag Browser Support
Element |
Chrome |
Edge |
Firefox |
Safari |
Opera |
<img> |
Yes |
Yes |
Yes |
Yes |
Yes |
Global Attributes
Event Attributes
Attributes
The following attributes like align, border, hspace, and vspace are not supported in HTML5 BUT supported attributes are mentioned below:
Attribute |
Value |
Description |
alt |
text |
Defines an alternate text for an image |
crossorigin |
anonymous |
Crossorigin attribute allow images from third-party sites that allow cross-origin access to be used with canvas |
height |
pixels
% |
Height attribute defines the height of an image |
ismap |
ismap |
Ismap attribute defines an image as a server-side image-map |
longdesc |
URL |
Longdesc attribute defines an URL to a detailed description of an image |
src |
URL |
Defines the URL of an image |
srcset |
URL |
Defines the URL of the image to use in different situations |
usemap |
#mapname |
Defines an image as a client-side image-map |
width |
pixels
% |
Defines the width of an image |