In this article we are going to explain what is img tag in html or how to add an image on web page using img tag with example.


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.


<img src="url" alt="some_text">


<img src="good_morning.jpg" alt="Good Morning Friends"/>  

Let's see an example of HTML image.

 <!DOCTYPE html>
    <title>Example of image tag </title>   
    <img src="good_morning.jpg" alt="Good Morning Friends" /> 


 how to use image tag in html

Attributes of HTML img tag

The src and alt are important attributes of HTML img tag. All attributes of HTML image tag are given below.

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. The location of image may be on the same directory or another server.

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.  

width: It is an optional attribute which is used to specify the width to display the image.

height: It specifies the height of the image.

border : the border  attribute to add border to the image

align: the align attribute to set image alignment.

I hope this article will help to you after reading.

 Let's check live example

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like