13.HTML Image
13.HTML Image
13.HTML Image
HTML Image
HTML img tag is used to display image on the web page.
HTML img tag is an empty tag that contains attributes only,
closing tags are not used in HTML image element.
Let's see an example of HTML image.
Output:
1) src
It is a necessary attribute that describes the source or path of the image. It instructs the
browser where to look for the image on the server.
2) alt
The alt attribute defines an alternate text for the image, if it can't be displayed. The
value of the alt
attribute describe the image in words. The alt attribute is considered
good for SEO prospective.
3) width
It is an optional attribute which is used to specify the width to display the image. It is not
recommended now. You should apply CSS in place of width attribute.
1/3
4) height
It h3 the height of the image. The HTML height attribute also supports iframe, image
and object elements. It is not recommended now. You should apply CSS in place of
height attribute.
Example:
1. <img src="animal.jpg" height="180" width="300" alt="animal image">
Output:
Note: Always try to insert the image with height and width, else it may flicker
while displaying on webpage.
1. <img src="animal.png" height="180" width="300" alt="animal image">
Output:
2/3
1. <img src="E:/images/animal.png" height="180" width="300" alt="animal image">
Note: If src URL will be incorrect or misspell then it will not display your image
on web page, so try to put correct URL.
Example:
1. <a href="https://www.javatpoint.com/what-is-robotics">
<img src="robot.jpg" height="100" width="100"></a>
Output:
Supporting Browsers
3/3