1

I'm following online tutorials to start learning HTML and I'm having trouble adding an image. What I'm doing is just typing into a txt (renamed as .html and with UTF-8 encoding, per the tutorial's instructions) document, then checking to see the code changes work properly by opening. However I cant seem to get the image to load properly when testing it, no matter what I do. Here is what I have in the text document:

<img src="C:\users\jason\desktop\website\curved.jpg">

I double checked that the path is correct, everything is spelled correctly, and that image is in the same folder as the html document. So what am I doing wrong here?

resevil239
  • 13
  • 1
  • 1
  • 3
  • The answer in the above question did indeed help me resolve my issue. – resevil239 Feb 07 '17 at 00:21
  • Just note this: a HTML file actually searches from where the file itself is. When you put the image within the same folder, or within a subfolder in the same folder, you can just call it with `src="curved.jpg"` or `src="images/curved.jpg"`. When it's a folder level lower, you can use `../` like so: `src="../curved.jpg"`. There is no need to actually go through your file system. – NoobishPro Feb 07 '17 at 00:22

2 Answers2

1

Try using the file:/// protocol if you want to link to local files.

<img src="file:///C:\users\jason\desktop\website\curved.jpg">
  • yeah, I saw that when the site suggested this was a duplicate, in the other question. Thats what worked for me. Also apparently I messed up the image I was trying to use which is why it wasn't opening even after I'd initially added that. I used a different image and it worked perfectly. – resevil239 Feb 07 '17 at 00:30
  • this protocol still works? when I'm using it, it doesn't display the picture. – Bando Aug 08 '19 at 08:31
1

Just double check that it is in fact a .jpg and not a .png for example, and try the following:

 <img src="curved.jpg">

I would also have the image saved in the same folder as the HTML file.

CoderGirl94
  • 214
  • 2
  • 12