Copyright © tutorialspoint.com
The HTML <img> tag is used to put an image in an HTML document.
In HTML the <img> tag has no end tag.
In XHTML the <img> tag must be properly closed.
The align, border, hspace, and vspace attributes of the image element are deprecated in HTML as well as in XHTML.
<img src="http://www.tutorialspoint.com/images/html.gif" alt="HTML Tutorial" /> |
This will produce following result:
![]() |
To Become more comfortable - Do Online Practice
Attribute | Value | Description |
---|---|---|
alt | text | Specifies alternate text |
align | top bottom middle left right | Specifies the aligmnet for the image. |
border | pixels | Deprecated - Specifies the width of the image border. |
height | pixels or % | Specifies the height of the image. |
hspace | pixels | Deprecated - Amount of white space to be inserted to the left and right of the object. |
ismap | URL | Defines the image as a server-side image map. |
longdesc | text | Specifies a URI/URL of a long description - this can elaborate on a shorter description specified with the alt attribute. |
usemap | URL | Defines the image as a client-side image map and used alongwith <map> and <area> tags. |
vspace | pixels | Deprecated - 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 %. |
Attribute | Description |
---|---|
class | Document wide identifier |
dir | Specifies the direction of the text |
id | Document wide identifier |
title | Specifies a title to associate with the element. |
style | Helps to include inline casecadubf style sheet. |
lang | Sets the language code. |
xml:lang | Sets the language code. |
Attribute | Description |
---|---|
onclick | Script runs when a mouse click |
ondblclick | Script runs when a mouse double-click |
onmousedown | Script runs when mouse button is pressed |
onmouseup | Script runs when mouse button is released |
onmouseover | Script runs when mouse pointer moves over an element |
onmousemove | Script runs when mouse pointer moves |
onmouseout | Script runs when mouse pointer moves out of an element |
onkeypress | Script runs when key is pressed and released |
onkeydown | Script runs when key is pressed |
onkeyup | Script runs when key is released |
Copyright © tutorialspoint.com