If you want to add some images on your webpage to make it more impressive and attractive then you need some images. So to add these images on your webpages HTML is giving you an image tag. This image tag is a very useful and most used tag to when we want to include images in the HTML web page. Also, we can manipulate this image by the given image attributes.
The syntax to insert an HTML Images in a web page is as follows:-
HTML Images Syntax
We can define images in HTML using the <img> tag.
<img> the tag contains only attributes. It has not a closing tag.
There is a src the attribute of the IMG that has an address of the image.
[cc lang=”html” tab_size=”2″ lines=”80″]
//if image in the same folder of your files
[/cc]
or
[cc lang=”html” tab_size=”2″ lines=”80″]
[/cc]
or
[cc lang=”html” tab_size=”2″ lines=”80″]
//you can also define the width and height of the image.
[/cc]
The Attributes of img tag in HTML
Generally, attributes are the properties of any elements to do some modification as per requirement. Some of the most used attributes of <img> tag are written below:
- src: src is a short form “source”. This src attribute is used to specifies the path for the source of the image where the image is located.
- alt: alt short form “alternate”. This is a very useful and also optional attribute. The purpose of using this tag is if an image is not available at a given path by you then this alt text will be visible at the place of the image.
- width: width is used to define the width of an image.
- height: height is used to define the height of the image
- align: align help to set the alignment for the image. We can align any image either left, right, center, etc. By default, it is set as left.