Dilemma about path names
Ok I've been designing sites for a short while, but I always run into this dilemma. Should I leave the ".." dots in the relative paths of the code of my web pages.
Could I leave as
<img src="../images/image1.jpg" alt="" />
or do I have to upload the code to the server without them like this:
<img src="/images/image1.jpg" alt="" />
I need them in my PC, I understand the server doesn't need them, but for updating or making changes I need to see the images and get to the files in other folders.
Thanks for the help...
The two paths you've given mean different things.
If the path starts ../ that means "go up one level"
If the path starts / that means "start at the root level"
So, from the file domain.com/content/articles/help/entry.htm, the following pairs are equivalent:
../access/reading.gif or /content/articles/access/reading.gif
key.htm or /content/articles/help/key.htm
../../../styles/main.css or /styles/main.css
In some cases, the two paths you've given will resolve to the same destination (ie, any time when you are within the first folder down), but they do have different meanings and can be used in different circumstances, whichever is appropriate to the site you're working on.
Thanks for your explanation, but that is not what I'm looking for.
I understand full paths and relative paths, my questions regards more towards the PC and Mac computers different ways of specifying the path names. The PC needs the ".." to specify the root directory, whereas the Mac doesn't.
What I need to know is how important it is to consider this and either keep the ".." in the code, or if I must remove it so users with a Mac don't have any trouble seen the page.
I don't know for sure because I've never tested it on a Mac, but I would put a 99.9% bet on either one working fine for Mac users running over http. Computers often behave differently when running files locally compared with running them over the internet, and this is probably one of those cases. As I said, whether you have the leading '..' or not changes the meaning of the path, so all browsing devices must deal with both types of links in the right way.
Let's put it another way - a lot of sites do use relative paths, so if a Mac couldn't understand them, that would be a third of the internet that was completely up the chuff for anyone using a Mac. I think we'd have heard about it being a problem if that was the case...
Great, thanks for the advice. And just to add, the main reason for my hesitation came from using the Adobe Bridge Browser Lab. It tested files running on a server, and whenever I tested the a browser running on a Mac it display as if it wasn't connecting to the styles file or the images. But I guess is not much of a reliable tool.
Thankful for the help.