HTML 4 img Tag

Also see HTML5 <img> Tag.

This page contains information about the HTML 4 version of this element. For a more up to date version, see HTML5 <img> Tag.


The HTML img tag is used for embedding images into an HTML document.

To use this tag, the image you specify in the src attribute needs to be available on a web server. This could be your own web server or another web server (such as PhotoBucket).

For more information on creating graphics for the web, check out the web graphics tutorial.

To link an image to another web page (or a larger version of the image), you simply nest the <img> tag inside an <a> tag. Here's an example of linking an image.

You can also link your image to an image map.

Example

Attributes

Attributes specific to this tag:
AttributeDescription
nameAssigns a name to an image. This is used when referencing the image with stylesheets or scripts. However, you should use the id attribute instead.
longdescSpecifies a URI/URL of a long description - this can elaborate on a shorter description specified with the alt attribute.
srcLocation of the image.
Other Attributes:
AttributeDescription
classDocument wide identifier.
idDocument wide identifier
altAlternate text. This specifies text to be used in case the browser/user agent can't render the image.
titleSpecifies a title to associate with the element. Many browsers will display this when the cursor hovers over the element (similar to a "tool tip").
styleInline style (CSS)
dirSpecifies the direction of the text
langLanguage code
ismapFor image maps. See HTML map tag
usemapFor image maps. See HTML map tag
alignFor alignment (left, center, right, justify).
widthSpecifies the width of the image.
heightSpecifies the height of the image.
borderSize of the image border. For no border use 0 (zero).
hspaceAmount of white space to be inserted to the left and right of the object. Deprecated.
vspaceAmount of white space to be inserted above and below the object. Deprecated.
onclickIntrinsic event (see event handlers)
ondbclickIntrinsic event (see event handlers)
onmousedownIntrinsic event (see event handlers)
onmouseupIntrinsic event (see event handlers)
onmouseoverIntrinsic event (see event handlers)
onmousemoveIntrinsic event (see event handlers)
onmouseoutIntrinsic event (see event handlers)
onkeypressIntrinsic event (see event handlers)
onkeydownIntrinsic event (see event handlers)
onkeyupIntrinsic event (see event handlers)

Try it Yourself!

Modify the code below, then click Update. See below for attributes.

HTML5 Tags

The information on this page is based on HTML version 4.01. Most modern browsers now support HTML5, which is the next version of HTML after HTML 4.01.

See HTML5 <img> Tag for the HTML5 version of the above element.

Also see this list of HTML 5 tags for the latest version of HTML.