The <img> tag is used to place an image on the web page.
This tag does not contain closing tag.
src is one of the attribute, it is mandatory and used to specify the image path.Syntax
These attribute are used to change the size of the images, it is not mandatory to specify but it highly recommended to use.
It doesn't change the images original size, but changes the size only when displaying on the web page.
If you set anyone of the width or height attribute value, the image will not stretch.
alt(alternative) attribute is used to show a tooltip when mouse is moved over the image.
Search engines, search and retrieves the image by the alt attribute value.
In the following example, you can see a tooltip text while you place mouse pointer over the image.
When an image path is incorrect, instead of the image the alt attribute value will be displayed.
In the following example, wrong image path is given, so instead of the original image an broken image icon is displayed along with the alternate text (This is the butterfly image).
We can create a image link using <a> tag and <img> tag
Already we have seen about the <a> tag in previous chapter.
You can just write the <img> tag inside the <a> tag.
The <figcaption> tag is used to specify a title or caption for a image.
The <figcaption> tag is written inside the <figure> tag.