HTML img Tag

The information on this page is based on HTML version 4.01 (which is the current version of HTML). The next version, HTML 5, is currently being written. Here's a list of HTML 5 tags.

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 <img src="/pix/milford_sound/milford_sound_t.jpg" width="225" height="151" alt="Milford Sound in New Zealand">
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!


Also see the HTML 5 version of HTML tags

Enjoy this page?

  1. Link to this page (copy/paste into your own website or blog):
  2. Link to Quackit using one of these banner ads.

Thanks for supporting Quackit!

Sponsored Link: Design CODE-FREE Websites

Check a Domain:

ZappyHost Logo
Webydo Banner Ad
Webydo Banner Ad