HTML Images helps to make beautiful websites which attract the visitors.
In HTML, <img> tag is used to show images (like jpg, png, gif etc.) on the web page.
HTML Image is defined by <img src="url"> syntax.
src stands for Source.
url stands for Uniform Resource Locator(where our resource is located).
<img> tag is an example of One-sided tag.
The alt attribute provides an alternative information of an image when the image is not displayed on the web page.
Alternative information is in the form of text which defines the title or summary of the image.
It helps the users to get information about the image which helps them to understand the web page without seeing the image.
Slow internet connection
An error in the src attribute
Incorrect image source link
It also helps blind persons to read web page because screen reader only read the text.
In the above, we have shown an example of HTML Image Alt Attribute.
Above, the link of the image is incorrect.
Incorrect link : favicon.pnx
Correct link : favicon.png
Extension of image is different.
So, as a result, we will get alt text visible on the screen.
The width and height attribute used to re-size an image.
In the above, we have shown an example of HTML Width and Height Attribute.
width="40" make the size of the image 40px and height="50" make the size of the image 50px.
Run the code to see the effect.