IMAGE TAG IN HTML
The HTML <img> tag is used to add images inside the webpage/website.
Nowadays website does not directly add images to a web page, as the images are
linked to web pages by using the <img> tag which holds space for the image.
The <img> tag has two required attributes:
src – It specifies the path to the image
alt – It specifies an alternate text for the image if the image for any reason
cannot be displayed on the webpage.
Syntax of image tag:
<img src=”” alt=”” width=”” height=””>
Attributes used in image tag :
Attribute Description
src Specifies the path to the image.
Provides alternate text for the image,
useful for informing users about the
alt
image and displaying in case of
network issues.
height Specifies the height of the image.
width Specifies the width of the image.
Specifies an image as a server-side
ismap
image map.
Specifies image sizes for different page
size
layouts.
Example 1: The implementation of the <img> tag along with src, width, height,
and alt attributes.
<body style="text-align: center;">
<h3>GeeksforGeeks logo</h3>
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png "
width="420" height="100"
alt="Geeksforgeeks.org">
</body>
Example 2: The implementation of the style attribute to add a border to
the image.
<body style="text-align: center;">
<h3>GeeksforGeeks logo</h3>
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/
geeksforgeeks-13.png"
width="420" height="100"
alt="Geeksforgeeks.org"
style="border:5px solid black">
</body>