Description

The <img> (short for image) tag defines an image in an HTML document. Images are not directly inserted into the document; they are linked to the HTML pages. The <img> element creates a holding space to embed the referenced image designated by the src attribute.

The following table summarizes the usages context and the version history of this tag.

Placement:Inline
Content:None. It is an empty element.
Start/ End Tag:Start tag: required, End tag: forbidden
Version:HTML 2, 3.2, 4, 4.01, 5

Note: The browser may replace the image with the alternative text defined in this element's alt attribute in the case of non-graphical browsers, or if the browser is unable to display the image because it is invalid or an unsupported type.

Syntax

The basic syntax of the <img> tag is given with:

HTML:<img src="URL" alt="text">; XHTML:<img src="URL" alt="text" />

The example below shows the <img> tag in action.

<img src="kites.jpg" alt="Flying Kites">
<img src="sky.jpg" alt="Cloudy Sky">
<img src="ballons.jpg" alt="Hot Air Ballons">

Tag-Specific Attributes

The following table shows the attributes that are specific to the <img> tag.

Global Attributes

Like all other HTML tags, the <img> tag supports the global attributes in HTML5.

Event Attributes

The <img> tag also supports the event attributes in HTML5.

Browser Compatibility

Element
<img>YesYesYesYesYes