HTML <img> Tag


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.


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


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


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.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 30th March 2024