<img>
HTML <img> (Image) Tag
Example
<img src="flowers.jpg" alt="Boy" width="300" height="200">
Meaning
The <img> element specifies a media object to be included in an HTML or XHTML document.
Usually, the object is a bitmap graphic image, but some implementations support movies, vector formats, and animations.
The <img> element has two required attributes.
- src - Specifies the source path to the image(vector can be used).
- alt - Specifies an alternate text for the image, if the image unable to load for some reasons.
Version: HTML 2, 3.2, 4, 4.01, 5
Standard Syntax
HTML: <img src="URL" alt="text">,
XHTML: <img src="URL" alt="text" />
Advertisement
Attributes
| Attribute | Value | Description |
|---|---|---|
| alt | text | Specifies an alternate text for an image |
| crossorigin | anonymous use-credentials |
Indicates if the fetching of the image must be done using a CORS request. |
| decoding | sync async auto |
Specifies an image decoding hint to the browser. |
| height | pixels | Specifies the height of an image. |
| ismap | ismap | ismap is a boolean attribute specifies that the image is a server-side image map. |
| loading | eager lazy |
loading attribute specifies how the browser should load the image. |
| referrerpolicy | no-referrer no-referrer-when-downgrade origin origin-when-cross-origin unsafe-url |
Specifies which referrer information to use when fetching an image |
| sizes | sizes | Specifies image sizes for a set of source sizes. |
| src | URL | src attribute specifies the URL of an image file to be displayed. |
| srcset | URL-list | srcset attribute specifies one or more strings separated by commas, indicating possible image sources for the user agent to use. |
| usemap | #mapname | usemap attribute makes the image support client-side image mapping. |
| width | pixels | Specifies the width of an image. |
Global Attributes
<img> element also supports the Global Attributes in HTML.
Event Attributes
<img> element also supports the Event Attributes in HTML.
By Default CSS Value(s)
Most of the browsers will display the <img> element with the following by default value(s)
img {
display: inline-block;
}
Related Tags:
<audio>,<embed>,<iframe>,<map>,<object>,<param>,<picture>,
portal>,<source>,<track> and<video>