View Full Version : I need help linking images using their relative path names

02-17-2009, 12:46 AM
I have been switching to coding everything by hand this year. I have an image called google.jpg on my desktop and i want to add it as an image to a webpage that im building on my local machine and then view it. I only want to use the relative path, not the absoutle path. The code i have is

<img src="google.jpg" width="1000" height="450" />.

The image displays as an broken image. Im not sure how to link to files on my local machine using their relative path names. What am im doing wrong in my code, and any refernce links that can help me with linking to files on my local machine using their relative path names would be appreciated, thanks.

02-17-2009, 01:20 AM
In order for <img src="google.jpg" width="1000" height="450" /> to work, google.jpg would need to be in the same folder as the html file. Should work if the html file is also on your desktop.

02-17-2009, 01:25 AM
That code only works if your html page is also located on your desktop (so, in the same folder as your image). You use "/foldername" to browse to a folder and "../" to go up a folder.

Suppose you have a folder structure like this (folders are written in caps):

- index.html
- image.jpg

Then, if you want to show image.jpg in index.html, you do

<img src="img/image.jpg">

If your folder structure is like this:

- image.jpg
- index.html
- image2.jpg

If you want to show both images in your index.html, you do it like this:

<img src="../website1/img/image.jpg">
<img src="image2.jpg">

I hope this is clear (and that I understood your question correctly :p).

02-17-2009, 01:46 AM
Thanks guys, i finally got it now, i repped both of your guys, thanks again.