HTML - <Img>

This element indicates a media object to include in an HTML document. Usually, the object is a graphic image, but some implementations support movies and animations.

Syntax

<IMG

ALIGN="BOTTOM | LEFT | MIDDLE | RIGHT | TOP"
ALT="alternative text"
BORDER="pixels"
CLASS="class name"
HEIGHT="pixels"
HSPACE="pixels"
ID="unique alphanumeric identifier"
ISMAP
LONGDESC="url of description file"
SRC="url of image"
STYLE="style information"
TITLE="advisory text"
USEMAP="url of map file"
VSPACE="pixels"
WIDTH="pixels"
onclick="script"
ondblclick="script"
onkeydown="script"
onkeypress="script"
onkeyup="script"
onmousedown="script"
onmousemove="script"
onmouseout="script"
onmouseover="script"
onmouseup="script">

Attributes

ALIGN This attribute controls the horizontal alignment of the image with respect to the page. The default value is LEFT. The others value are ABSBOTTOM , ABSMIDDLE, BASELINE, and TEXTTOP.
ALT This attribute contains a string to display instead of the image for browser that cannot display images.
BORDER This attribute indicates the width in pixels of the border surrounding the image.
CLASS This attribute is set to indicate the class or classes that a particular element belongs to. A class name is used by a style sheet to associate style rules to multiple elements at once.
HEIGHT This attribute indicates the height in pixels of the image.
HSPACE This attribute indicates the horizontal space in pixels between the image and surrounding text.
ID This attribute specifies a unique alphanumeric identifier to be associated with an element. Naming an element is important to being able to access it with a style sheet, a link, or a scripting language. Names should be unique to a document and should be meaningful.
ISMAP This attribute indicates that the image is a server-side image map. User mouse actions over the image are sent to the server for processing.
LONGDESC This attribute soecifies a URL of a document that contains a long description of the image. This attribute is used as a complement to the ALT attribute.
SRC This attribute indicates the URL of an image file to be displayed.
STYLE This attribute specifies an inline style associated with the element. The style information is used to determine the rendering of the affected element.
TITLE This attribute supplies advisory text for the element that may be rendered as a tool tip when the mouse is over the element. A title may also simply provide information that alerts future document maintainers to the meaning of the element and its enclosed content.
USEMAP This attribute makes the image support client-side image mapping. Its argument is a URL spcifying the map file, which associates image regions with hyperlinks.
VSPACE This attribute indicates the vertical space in pixels between the image and surrounding text.
WIDTH This attribute indicates the width in pixels of the image.

Event Handlers

onclick Indicates that the element has been clicked.
ondblclick Indicates that the element has been double-clicked.
onkeydown Indicates that a key is being pressed down with focus on the element.
onkeypress Describes the event of a key being pressed and released with focus on the element.
onkeyup Indicates that s key is being released with focus on the element.
onmousedown Indicates the press of a mouse button with focus on the element.
onmousemove Indicates that the mouse has moved while over the element.
onmouseout Indicates that the mouse has moved away from an element.
onmouseover Indicates that the mouse has moved over an element.
onmouseup Indicates the release of a mouse button with focus on the element.

Examples

<IMG SRC="image1.jpg" ALT="image description" HEIGHT="100" WIDTH="100">
<IMG SRC="image2.jpg" USEMAP="map name" BORDER="0" HEIGHT="100" 
           WIDTH="100" ALT="image description">
<A HREF="otherpage.htm"><IMG SRC="image3.gif" WIDTH="100" HEIGHT="100" 
           ALT="Link to another page"></A>