HTML Img Tag is used to insert an image in the HTML document. The <img> element has two required attributes src and alt. src refers to the location of the image file and alt refers to the alternative text to the image which will be image's short description.
Syntax
This will produce following result
The below table contains Image Attributes and their description which is supported by HTML version.
Attribute Name | Attribute Value | Attribute Description |
---|---|---|
src | URL | refers to the URL of an image |
alt | text | refers to the alternative text to the image which will be image's short description |
border | pixels | refers to width of the border around an image |
height | pixels | refers to height of the image |
width | pixels | refers to width of the image |
align | left, middle,right, top, bottom | refers to alignment of the image with respect to its surrounding context |
hspace | pixels | refers to the whitespace on left and right side of an image |
vspace | pixels | refers to the whitespace on top and bottom side of an image |
ismap | ismap | refers to an image as a server side image map |
usemap | ismap | refers to an image as a client side image map |
longdesc | URL | refers to URL to the document containing long description of an image |
Above attributes can be more easily understood by following examples
This will produce following result
This will produce following result
This will produce following result
Welcome to techstrikers! Welcome to techstrikers!This will produce following result
Welcome to techstrikers! Welcome to techstrikers!This will produce following result
Welcome to techstrikers! Welcome to techstrikers!