By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

HTML IMG Tag

How the IMG tag is used to insert images, and used for image maps. This reference is about the IMG element in HTML, and includes useful examples.

Edited: 2014-12-28 07:08

The HTML IMG element is used to insert images in pages.

When you use the IMG element inside a elements, the image becomes a click-able link. Read more about that in the Images and Links Tutorial.

The IMG element is a inline element, and has no closing tag.

Use as image map

The IMG element can also be used to create an image map. If you are using the ismap attribute, the image must be inside an a element. When the user then clicks the link, the screen coordinates will be sent to the server, where the document resides.

Attributes

Attribute:Value:Description:
AttrsOther AttributesCommon, Event, I18n
nameCharacter DataGives the image a name, can be used for scripting purposes.
usemapURILocation of client-side image map.
ismapismapUse image as server-side image map.

HTML img Example

The below will create a normal image, inside a paragraph.

<p><img src="MyImage.jpg" alt="An Image"></p>

You can also use an image as a link, this is useful when creating buttons. If you want your links to have a hover effect, such as a button in its pushed down state, and normal state, then check out the Hover effects on Links tutorial.

Below is an example which uses a image as a link:

<p><a href="about.html"><img src="MyImage.jpg" alt="Image linking to the About Page."></a></p>