Solution 1 :

Try putting the image in the same folder location as your html file. Then use:

<img src="/img.png" alt="image">

If this work then it is something to do with the folder structure and file path. Also, you can right click on the file in VS Code and use copy relative path to get the file location to add to your img src.

Also, have you tried:

<img src="images/img.png" alt="image">

Solution 2 :

Check if the names of the image and the folder are correct, and put the images folder in the same folder as the website.

If the image is in the folder “images”, and this folder is in the same folder as the website, use this:

<!Doctype html>
<html lang="en">
<head>
    <title>And</title>
</head>
<body>
    <img src="images/img.png" alt="image">
</body>
</html>

Another option is to put the image in the same folder as the website. Then the code will be:

<!Doctype html>
<html lang="en">
<head>
    <title>And</title>
</head>
<body>
    <img src="img.png" alt="image">
</body>
</html>

Problem :

I’m trying to make this Html work where I have the code folder in D:andhtmlabc.html and the image that I want to access in D:imagesimg.png and for this I’m writing this

<img src="../../images/img.png" alt="image">

But this is not working and only showing the alt text on the browser. When using tag for this then the link shown when opened shows that Cannot GET /images/img.png. I have no idea what I’m doing wrong but I’m sure that the problem is in the way I’m giving the location of the file. But if I’m using a image in the same folder as the code or a folder in the code’s folder or even in the and folder then it’s working fine like this

<img src="../img.png">

I’m using Vscode for now but this is not working even in Notepad

Comments

Comment posted by I_love_vegetables

yes you need to put the image in the same folder/directory as the html file. It wont work if you put the image somewhere else outside the html file’s folder

Comment posted by Weyers de Lange

The image, where is it? in you public folder of you project? or in your D: drive?

By