Anyone see why this img isn't loading?

Hi all,

Can anyone see anything wrong with this img tag?

img src="/resources/images/hacksaw.jpeg" alt=“DasmotoBrushes”
<img src="/resources/images/hacksaw.jpeg" alt="DasmotoBrushes">

The picture doesn’t load but the src is correct.

Any help would be greatly appreciated :slight_smile:

Hello and welcome to the forums @micro1231448206

Is the file trying to access it located in the resources folder?

I have also heard that since slashes are used to close a HTML element you have to use backslashes. You should get a second opinion on that though.

Hi,

Thanks for the welcome!

Yes it is. Like I said it works within VS but not on the web page.

no difference when I change the / to \

Yeah, that’s… untrue.

Generally speaking, even though Windows uses backslashes \ in its paths, the values you put in your HTML in things like the src="" attribute should use forwardslashes /. (*nix systems do that for filepaths anyway.)

You’d only probably want to use a \ if you were hardcoding an absolute path to something, e.g.:

<img src="C:\my_stuff\images\logo.png">

but I don’t think that absolute paths are generally a good idea. :slight_smile:

Since you seem to be working in Visual Studio Code, you should be able to do ALT + Click on that URI (/resources/images/hacksaw.jpeg) and VSCode will open the file.

If the file doesn’t open, your path is wrong. If the file does open, it should work when you view the page in a browser.

3 Likes

Good to know, I have been wondering about that since I heard it.

1 Like

Hi,

Yes it does work when you ALT + Click as I guess it’s because it knows wherethe pictures are on my server??? I don’t know, but whatever reason it doesn’t show on the webpage

Hi All,

Hope you are doing well!

I am having the same issue. I had downloaded the image and tried to use the link from local directory. All the images in the html worked fine, but I was not able to change the background image for the heading " Dasmoto’s Arts and Crafts" in CSS . Althought I had copied the path and pasted it, the link was broken, as I could see that the link was not underlined till the end. Then I changed the link to background-image: url(./Image\ 1.jpeg); and this worked. I am using VS code and Mac Os. Can anyone let me know what was the issue here?