SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Location
    USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

    e.g.:

    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...

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    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.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Location
    USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    I don't know for sure because I've never tested it on a Mac, but I would put a 99.9&#37; 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...

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Location
    USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •