HTML <img> tag
HTML <img> tag
The <img>
tag is used to add an image into a document.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<img src="books.png">
</body>
</html>
Attributes
The following are the attributes of <img> tag. Also try Global attributes.
Attribute | Value | Explanation |
---|---|---|
alt | text | Specifies an alternate text for an image. |
crossorigin |
| Allow images from third-party sites that allow cross-origin access to be used with canvas without being "tainted". |
height | px | Specifies the height of an image. |
ismap | - | Specifies that the image is part of a server-side map. |
sizes | (media) px,px | Specifies image sizes for different media condition. |
src | URL | Specifies the URL of the image (source). |
srcset | "URL, URL, ..." | Specifies an array of possible URL's for an image. |
usemap | #id | Specifies the partial URL (starting with #) of an image-map associated with the element. |
width | px | Specifies the width of an image. |
Deprecated Attributes
The following attributes should not be used in any case.
Attribute | Value | Explanation |
---|---|---|
align |
| Specifies the alignment of the image. |
border | px | Specifies the border of the image. |
hspace | px | Specifies the white space to insert to the left and right sides of the image. |
longdesc |
| Specifies a link to a more detailed description of the image. |
name | text | Specifies a name for the image. |
vspace | px | Specifies the white space to insert to the top and bottom side of the image. |
Reminder
Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in HTML.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.