Home > OS >  HTML error when attempting to use image in the same folder
HTML error when attempting to use image in the same folder

Time:05-06

Let's say I have a folder Block with the following files within...

Block
   index.js
   Block.js
   Block.scss
   Block_Image.png

Within the Block.js file, I attempt to grab and display the image with...

<img src="Block_Image.png alt='Picture of block' />

Why do I get a 404 Not Found error when running it? Only the alt text appears where the image should be. I have tried using different file paths, and I get the same error every time. Thanks for the help!

CodePudding user response:

In your code it seems your forgot an ".
If you didn't, try this :

<img src="./Block_Image.png" alt='Picture of block' />

CodePudding user response:

have you tried using "Block/Block_Image.png" ? If the html is on one level up, then it will look up in that folder.

CodePudding user response:

Hit F12 and check if something is blocking. If not. I would try to inspect and open image src in new tab, that will help us identifying the issues with the image url.

  • Related