HTML <img> Tag

Advertisements


Description

The HTML <img> tag is used to put an image in an HTML document.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML  Tag</title>
</head>
<body>
<img src="http://www.tutorialspoint.com/images/html.gif" alt="HTML Tutorial" height="150" width="140" />
</body>
</html>

This will produce following result:

HTML Tutorial

Global Attributes

This tag supports all the global attributes described in - HTML Attribute Reference

Specific Attributes

The HTML <img> tag also supports following additional attributes:

AttributeValueDescription
align top
bottom
middle
left
right
Deprecated-Specifies the alignment for the image.
alt textSpecifies alternate text
border pixelsDeprecated - Specifies the width of the image border.
crossoriginhtml-5anonymous use-credentialsIt allows images from third-party sites that allow cross-origin access to be reused with canvas.
height pixels or %Specifies the height of the image.
hspace pixelsDeprecated - Amount of white space to be inserted to the left and right of the object.
ismap URLDefines the image as a server-side image map.
longdesc textDeprecated-Specifies a URI/URL of a long description - this can elaborate on a shorter description specified with the alt attribute.
src URLthe url of an image
usemap #mapnameDefines the image as a client-side image map and used alongwith <map> and <area> tags.
vspace pixelsDeprecated - Amount of white space to be inserted to the top and bottom of the object.
width pixels or %Sets the width of an image in pixels or in %.

Event Attributes

This tag supports all the event attributes described in - HTML Events Reference

Browser Support

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes

html_tags_reference.htm

Advertisements