img src tag with examples

The src attribute of IMG tag

The src is an attribute of <img> tag of HTML. The img’s src stands for source, i.e. specifying image source where image will be pulled.

In img src attribute you can specify relative path e.g. if your domain is: then img src can be:

<Img src = “images/image.png”/>. It will be taken as

Alternatively you can specify absolute path like this:

<Img src = “”>

If you are using images from same domain then you should use relative path. If you are using third party images (images from other URL) then specify absolute path.

See below “src” examples with relative and absolute path:

Using img tag with src and alt attributes example

alt stand for alternative text. This is quite useful for SEO purpose as well. For example google search for images. Also if somehow image is not displayed, due to user’s slow connection or some other reason the alt text will be displayed.

The example below shows using img src and alt attributes.

You can use images linked to other web pages of your website or some other website. In order to link images to other web pages you can nest <a> tag with <img> tag. Or use src inside HTML link tag.

The example below shows how to link an image to other web pages by using src.

Also see HTML img | HTML href | HTML tutorial

Was this article helpful?

Related Articles

Leave A Comment?