Insert image in HTML | Use of <Img> Tag in HTML with Example
How to work with images in HTML and explain in detail <img/> tag important attributes?
Ans:
To add an image in HTML, we can use <img> element.
<img> element is a self-closing tag which means it doesn’t have a closing tag.
e.g. <img src=”Manas.jpg” alt=”This is an image of Manas”>
“Src” is a source that is an attribute that determines the source of an image for example- the image can be from a directory or local system and from online websites.
“Alt” is an alternative text which describes the description of the image. So when the image fails to load the alt text is displayed.
If the image size is big then e take attributes such as height=” ”, width=” ” and reduce the pixel of the image according to the need that we want to display in the website
e.g.
<img src= “image.jpg” alt= “This is a description of the image” width= “400px” height= “200px” />
Subscribe to my newsletter
Read articles from Manas Barman directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Manas Barman
Manas Barman
I am a Electrical Graduate. Also,I am a Full stack Web Developer.