Media & Embedded Content
HTML <img> Tag
The <img> tag is used to embed an image in an HTML page.
Definition and Usage
The <img> tag is used to embed an image in an HTML page.
Standard Syntax:
<img>Interactive ExampleRunnable
HTML <img> Example
htmlLive code demonstration for the <img> tag. Click "Try it Yourself" to edit and experiment in real time.
<div style="font-family: system-ui, sans-serif; padding: 16px; background: #ffffff; border-radius: 8px; border: 1px solid #e2e8f0; color: #0f172a;">
<img src="img_girl.jpg" alt="Girl in a jacket" width="500" height="600">
</div>Attributes for <img>
12 Supported Attributes| Attribute | Values | Default | Description |
|---|---|---|---|
| alt | text | none | Specifies an alternate text for an image |
| crossorigin | anonymous use-credentials | none | Allow images from third-party sites that allow cross-origin access to be used with canvas |
| height | pixels | none | Specifies the height of an image |
| ismap | ismap | none | Specifies an image as a server-side image map |
| loading | eagerlazy | none | Specifies whether a browser should load an image immediately or to defer loading of images until some conditions are met |
| longdesc | URL | none | Specifies a URL to a detailed description of an image |
| referrerpolicy | no-referrerno-referrer-when-downgradeorigin origin-when-cross-originunsafe-url | none | Specifies which referrer information to use when fetching an image |
| sizes | sizes | none | Specifies image sizes for different page layouts |
| src | URL | none | Specifies the path to the image |
| srcset | URL-list | none | Specifies a list of image files to use in different situations |
| usemap | #mapname | none | Specifies an image as a client-side image map |
| width | pixels | none | Specifies the width of an image |
Global Attributes
The <img> tag also supports the standard global attributes in HTML, including class, id, style, title, hidden, and data-*.
Event Attributes
The <img> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.
Browser Compatibility
ChromeEdgeFirefoxSafariOpera
More Tags in Media & Embedded Content
View All 123Tags →<applet>Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.<area>The <area> tag defines an area inside an image map (an image map is an image with clickable areas).<audio>The <audio> tag is used to embed sound content in a document, such as music or other audio streams.<canvas>The <canvas> tag is used to draw graphics, on the fly, via scripting (usually JavaScript).<embed>The <embed> tag defines a container for an external resource, such as a web page, a picture, a media player, or a plug-in application.<iframe>The <iframe> tag specifies an inline frame.