Search code examples
htmlcssimagevisual-studio-codevscode-extensions

Image not displayed in vs code


I use VS Code, and Live Server extension, I am trying to put an image with the <img> tag, the image was in the same folder and named coin.png, I tried to type <img src="coin.png>" but this is what I get in the browser here, I tried to see the browser's console and I got this message coin.png:1 Failed to load resource: the server responded with a status of 404 (Not Found), the weird thing is that it works with any other IDE, why does that happen and how to solve it?


Solution

  • you must use relative path or absolute path from your html file to your image file like this

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

    If your image file is in the same place with your html file Or

    <img src="[path to your image file]/coin.png" />