Relative Hyperlinks with Images

megan1989

Baseband Member
Messages
29
Location
USA
Here is how I am attempting to do this:
< img src="../yurt.jpg" alt="Pacific Trails Yurts" width="295" height="215">

The image is located one level up from the main folder that I have the webpage in. And as of now, it does not display the image only the alternate text, which means I am not linking it correctly. Also is there a way to do with an external style sheet, as I have images referenced in that which are also located one level up from the main folder.

background-image: url(ptrbackground.jpg);
list-style-image: url(marker.gif);


Also I don't know if this matters, but I am using Web Expressions 4 program. Thanks
 
Last edited:
Okay, apparently I was not going far enough back with the relative hyperlink it was solved by issuing this to the code "Pacific/images/yurt.jpg"
 
So you page is located inside a folder inside the images folder?
That's a weird setup!
 
Maybe I misunderstood you, but my webpage is located inside a main folder and inside the main folder is another folder with the images. I suppose it does sound a bit weird, but I promise this makes my folders seem more organized. Thank you for your reply.
 
what I mean is.

consider the path

c:\websites\Pacific\pages\main.html
c:\websites\Pacific\images\yurt.jpg

< img src="../yurt.jpg" alt="Pacific Trails Yurts" width="295" height="215">

this doesn't work, because the link is located at c:\websites\pacific\pages, and is just ../ (go up one) so it's looking for the image file in c:\website\pacific\yurt.jpg and failing.

using an absolute (Pacific/images/yurt.jpg) instead of relative (../images/yurt.jpg)
will work, however, if your relative link is correct, both ways will work, (provided you don't go out of the site*)

when you say that your images are located one folder up from your page data it sounds like your folder stucture is
c:\websites\pacific\images\yurt.jog
c:\websites\pacific\images\pages\main.html (then just linking ../yurt.jpg should have worked!)

*when I say don't go outside the folder I mean that you have a thing configured either as a source directory in IIS or as a document root in apache.

if c:\websites\pacific is the document root for the pacific website,
no matter how many ../'s you put you can't traverse up the tree further than the document root.
so when you land on the site you land at c:\websites\pacific\index.html you can't run ../../windows/system32/cmd.exe!

but also you can't use data from other sites.
so c:\websites\pacific\index.html can't load objects from
c:\websites\atlantic\images\ because they are different websites, -linking using /atlantic/images won;t help either, you;d have to use http://www.atlanticsite.com/images/link

(that's why I was confused about your folder structure.
 
Thank you for your reply, that makes sense. I will make a note of that information you provided, so hopefully I won't run into that error again.:)
 
Back
Top Bottom