HTML <img> Tag

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

Description

The <img> HTML element is intended for displaying images in the graphic format GIF, JPEG, SVG or PNG on a web page. The address of the image file is set via the src attribute. If necessary, you can make the image a link to another file by placing <img> in the container <a>.
Pictures can also be used as image maps when a picture contains active areas that act as links. Such a map in appearance is no different from a conventional image, but it can be divided into invisible zones of various shapes, where each of the areas serves as a link.

Properties

Permitted Parents
Any element that accepts embedded content
Content
None. It is an empty element.
Start/End Tags
Start tag: required, End tag: forbidden

Example

<img alt="Sunset Image" src="images/sunset.jpg" width="300" height="226">

Attributes

Attribute Definition
name Assigns a name to an image. This is used when referencing the image with stylesheets or scripts. However, you should use the id attribute instead.
src Location of the image.
alt Alternate text. This specifies text to be used in case the browser/user agent can't render the image.

Global Attributes

The <img> tag also supports the Global Attributes in HTML5

Event Attributes

The <img> tag also supports the Event Attributes in HTML5

Browser Support

The following table will show you the current browser support for the HTML <img> tag.

Desktop
Edge Chrome Firefox Opera Safari
1211151
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
18414114.4

Last updated by CSSPortal on: 30th March 2024