Attribute – Img Src Attribute

Img Src Attribute

The <img src> attribute refers to the source of the image you want to display. The img tag will not display an image without the src attribute. However, if you set the source to the location of the image, you can display any image.

There is an image of the Codevarsity Logo located at

You can set that as the image using the src attribute.

<html> <head> <title>Img Src Attribute Example</title> </head> <body> <img src=""> </body> </html>

The above code displays like this:

The Codevarsity Avatar

The src attribute is supported by all browsers.

You can also have a locally hosted file as your image.

For example, <img src="images/Codevarsity.jpeg> would work if you had a folder called images which had the Codevarsity.jpeg inside, as long as the ‘images’ folder was in the same location as the index.html file.



More Information:

This article needs improvement. You can help improve this article. You can also write similar articles and help the community.