HTML img

From Htmlpedia
Jump to: navigation, search

HTML Element IMG

Definition and Usage

The <img> tag defines an image.
Often used in conjunction with the style tag to add widths, heights and borders.


Examples

<img src="happy.gif" alt="happy face">
<img src="happy.gif" alt="happy face" style="width: 16px; height: 16px">

Attributes

Required attributes

Attribute Value Description DTD
alt CDATA short description of the image HTML4
Strict
Transitional
Frameset
src  %URI; URI of image to embed HTML4
Strict
Transitional
Frameset

Optional attributes

Attribute Value Description DTD
align top
bottom
middle
left
right
Specifies the position of the image within the surrounding text. Deprecated. Use styles instead.

The following values for align concern the object's position with respect to surrounding text:

  • bottom: means that the bottom of the object should be vertically aligned with the current baseline. This is the default value.
  • middle: means that the center of the object should be vertically aligned with the current baseline.
  • top: means that the top of the object should be vertically aligned with the top of the current text line.

Two other values, left and right, cause the image to float to the current left or right margin.

HTML4
Transitional
Frameset
border size in pixels Specifies the width of an image border. Deprecated. Use styles instead HTML4
Strict
Transitional
Frameset
height size in pixels Tell user agents to override the natural image height in favor of this value. Deprecated. Use styles instead HTML4
Strict
Transitional
Frameset
hspace size in pixels Defines the white space on the left and right side of the image. Deprecated. Use styles instead HTML4
Transitional
Frameset
ismap N/A boolean attribute definig the image as a server-side image map HTML4
Strict
Transitional
Frameset
longdesc  %URI; Link to a long description of the image HTML4
Strict
Transitional
Frameset
usemap  %URI; Defines the image as a client-side image map. See also map and area. HTML4
Strict
Transitional
Frameset
vspace size in pixels Defines the white space on the top and bottom of the image. Deprecated. Use styles instead HTML4
Transitional
Frameset
width size in pixels Tell user agents to override the natural image width in favor of this value. Deprecated. Use styles instead HTML4
Strict
Transitional
Frameset

Standard Attributes

id, class, title, style, dir, lang

Event Attributes

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup


Tags in Tag

none


References


Back to HTML Elements