PDA

View Full Version : Simple question about files/directories



gnubler
27 Oct 2006, 12:18 AM
I'm using Firefox's web developer addon to play around with a page I'm developing. Initially, I had this file (print.html) just sitting on my desktop for easy access, as well as a directory called "images", to which I was linking images in my CSS and HTML. I since moved both the print.html file and the "images" directory to a sub-directory within my hard drive - both into the same subdirectory - but now the images just don't show up. When I hover over an image link and look at the status bar in my browser window, I see the path of the original location of these files (my desktop). But that's nowhere in the code - the link path is relative.

The image path in my HTML is like this:

<img src="images/print_c.jpg"

Am I missing something here? If both the HTML file and the images directory are within the same enclosing directory, shouldn't the path be relative like this?

Duh...

Wickham
27 Oct 2006, 01:27 AM
Links to an html file in the same folder (directory) can be simply inserted between the tags as filename.html .

If the file is in a different folder the code is more complicated. For every movement to a lower level add / before filename.html or folder name (but not when accessing a folder or filename in the same folder); for every movement up add ../

Consider the following folder arrangement:-

folder1------->folder2------>folder3
folder1------->folder4
folder1 has another folder4 in it as well as folder2.

Assume your html file is in folder2.

If the target file is in folder3 - directly below folder2 - the link code has to go directly down so the link will be:-

<a href="folder3/filename.html">

If the target file is in folder1 - directly above folder2 - the link code has to go directly up so the link will be:-

<a href="../filename.html">

If the target file is in folder4 the route is up to folder1 then down to folder4; the link code will be:-

<a href="../folder4/filename.html">

Play around with the options until you get it right.