w3resource logo

HTML img tag and element - HTML tutorials

HTML img tag and element

Secondary Nav


1. HTML img (image) element embeds an image in an HTML document.

2. The img element is an empty element. It starts with <img> tag and does not have any end tag.

3. The value of the src element of img element holds the URI representing the location of the image.


<img src="location of the image" / >


HTML img element is a part of HTML object, image and applet.

Whether both start and end tags are required

Start tag is required but end tag is forbidden.

Can contain

HTML img element can contain any other elements.

Can reside within

HTML img element can reside within Inline elements, Block-level elements except pre.



id, class.

language information and text direction

lang, dir.






onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup.

alternate text


client side image maps

ismap, usemap.

visual presentation

align, width, height.

Supported doctypes

HTML 4.01 Strict, HTML 4.01 Transitional, and HTML 4.01 Frameset.

Example of using HTML img element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML img tag example - HTML tutorial | w3resource</title>
<p><img src="/images/layout.gif" alt="html img tag example" 266" height="239"></p>


html img element

View this example in a separate browser window

HTML img tag example.

Join our Question Answer community to learn and share your programming knowledge.

Help the community:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number