Tutorials Point


  HTML Home

  HTML Tags Reference
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

HTML <img> tag




Advertisements

Function:

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

Difference between HTML and XHTML:

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.

Example:

<img src="http://www.tutorialspoint.com/images/html.gif" alt="HTML Tutorial" />

This will produce following result:

HTML Tutorial

Online Practice:

To Become more comfortable - Do Online Practice

Attributes:

AttributeValueDescription
alttextSpecifies alternate text
aligntop
bottom
middle
left
right
Specifies the aligmnet for the image.
borderpixelsDeprecated - Specifies the width of the image border.
heightpixels or %Specifies the height of the image.
hspacepixelsDeprecated - Amount of white space to be inserted to the left and right of the object.
ismapURLDefines the image as a server-side image map.
longdesctextSpecifies a URI/URL of a long description - this can elaborate on a shorter description specified with the alt attribute.
usemapURLDefines the image as a client-side image map and used alongwith <map> and <area> tags.
vspacepixelsDeprecated - Amount of white space to be inserted to the top and bottom of the object.
widthpixels or %Sets the width of an image in pixels or in %.

Standard Attributes:

AttributeDescription
classDocument wide identifier
dirSpecifies the direction of the text
idDocument wide identifier
titleSpecifies a title to associate with the element.
styleHelps to include inline casecadubf style sheet.
langSets the language code.
xml:langSets the language code.

Event Attributes:

AttributeDescription
onclickScript runs when a mouse click
ondblclickScript runs when a mouse double-click
onmousedownScript runs when mouse button is pressed
onmouseupScript runs when mouse button is released
onmouseoverScript runs when mouse pointer moves over an element
onmousemoveScript runs when mouse pointer moves
onmouseoutScript runs when mouse pointer moves out of an element
onkeypressScript runs when key is pressed and released
onkeydownScript runs when key is pressed
onkeyupScript runs when key is released

Printer Friendly

Advertisements


  

Advertisements