The Image Tag

ken's picture

Opening tag : <IMG>
Closing tag: -

Purpose:
The Image tag is used to add images to a webpage. There is no closing tag for the IMG tags, but it is necessary to specify the SRC or source parameter, to specify where the image can be found.

Attributes:
Align=alignment
- Specifies how the image should be aligned. The choices available are LEFT, RIGHT and CENTER.

Alt=string
- It is good practice to use the ALT tag. The ALT or alternative tag contains some text which is displayed for users who are unable to see the pictures. The text is also displayed while the image is loading.

Border=#
- Specifies the width in pixels of a border around the image.

Class=class
- Instructs the browser to format the picture using the specified class style.

Dir=direction
- Useful for languages that should be read from right to left - in this case the direction of the alt tag is specified.

Event=Javascript
- Assigns some javascript to an event.

ID=Name
- Allows an ID to be specified for the image.

Height=#
- Specifies the height of the image.

Hspace=#
- Specifies the number of pixels of white space to be left to the left and right of the image.

Ismap
- Indicates the image is associated with a server side image map.

Lang=language
- Specifies the language for the ALT tag.

Longdesc=url
- Allows a longer description of the image to be stored in another file specified in the url.

Name=name
- A name used to reference the image from an external file - normally the ID is used instead.

Src=URL
- The source of the image.

Style=style
- Specifies a style to use when formatting the image.

Title=title
- Specifies a Title for the image.

Usemap=URL
- Specifies the URL of an image map for this image.

Vspace=#
- Specifies the number of pixels of white space to be left above and below the image.

Width=#
- Specifies the width of the image.

Example:

<IMG Src="mypic.jpg" alt="a Picture of Me!">

Related Tags:

<area></area> - Area Tag.

Back to:
Alphabetical Guide
Guide By Type


Comments

Ralph van den Berg's picture

Using alt and title together

I believe it to be good practice to use alt and title tags in images at the same time. Alt tags are good for spiders or images that won't load for some reason, but the title bit is good for your viewers, because in Firefox, when you mouse-over an image, it displays the title bit, unlike IE which will show you alt if no title is specified. So use both, it's OK if they're both the same.

---Ralph van den Berg
visit RalphvandenBerg.com