w3resource logo


HTML img tag and element - HTML tutorials

HTML img tag and element

Secondary Nav

Description

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.

Syntax

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

Category

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.

Attributes

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Events

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

alternate text

alt.

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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML img tag example - HTML tutorial | w3resource</title>
</head>
<body>
<p><img src="/images/layout.gif" alt="html img tag example" 266" height="239"></p>
</body>
</html>

Result

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