<img> tag is an HTML element used to insert images into a web page. It is a self-closing tag and doesn’t require a closing tag. The
<img> tag has several attributes that can be used to customize the appearance and behavior of the image.
Here’s an example of how to use the
<img src="image.jpg" alt="Description of the image">
In this example, the
src attribute specifies the path to the image file, and the
alt attribute provides a description of the image. The
alt attribute is important for accessibility because it provides a text alternative for users who are unable to see the image.
There are several other attributes you can use with the
<img> tag to customize the image, including:
height: These attributes specify the width and height of the image in pixels.
title: This attribute provides additional information about the image when the user hovers over it with their mouse.
align: This attribute specifies how the image should be aligned with respect to surrounding text. Possible values include “left”, “right”, “center”, and “justify”.
border: This attribute specifies the border size around the image in pixels.
Here’s an example of using some of these attributes:
<img src="image.jpg" alt="Description of the image" width="500" height="300" title="This is a picture of a beautiful sunset" align="center" border="1">
<img> tag is an essential element for including images in a web page. By using the different attributes available, you can customize the appearance and behavior of the image to fit your needs.