<img> tag is used to add an image in an HTML document.
☛
The <img> tag does not have an end tag </img> .
☛
This tag need two required attributes src and alt.
☛
You can also nest <img> tag inside
<a> tag to make it hyperlink
or link to another page.
☛
In fact images are not added in HTML source code, images are linked to HTML pages.
see source code, after the image page load you will not found any image in notepad, only link code will be displayed.
How to use image as a hyperlink ? :
☛
To make a image a clickable hyperlink use <img> tag inside the <a> tag as shown below :
HTML [Edit your code here]
Result / Output [Browser]
<img> Tag Support Following Attributes
Attribute
Value
Description
align
top bottom middle left right
Defines the alignment of an image.
(Unsupported/Unconsistent in HTML5)
alt
text
Specifies an alternate text if image not load then it will display these text also.
border
pixels
Defines the width of the image border.
(Unsupported/Unconsistent in HTML5)
crossorigin
anonymous use-credentials
Allows images from third-party sites that allow cross-origin access to be reused with canvas.
height
pixels or %
Defines the height of the image.
hspace
pixels
Defines white space to be inserted to the left and right of the image.
(Unsupported/Unconsistent in HTML5)
ismap
URL
Defines the image as a server-side image map.
longdesc
text
Defines a URL/URI to a detailed description of an image.
src
URL
Defines the url of an image.
usemap
#mapname
Defines the image as a client-side image map and used alongwith <map> and <area> tags.
vspace
pixels
Defines white space to be inserted to the top and bottom of the image.