SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    ********* Addict WP1's Avatar
    Join Date
    Aug 2000
    Location
    New York , USA
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I just want to double check this before I finalize a page template.

    Should I write links which are on my own site as,

    <A HREF="presskit.html"> with NO slash

    OR

    <A HREF="/presskit.html"> with the FORWARD slash??

    I find the info on this confusing and both methods seem to work but I know there is suppose to be a good reason why a webmaster is suppose to use one over the other. I just have not seen or read a consistent opinion about this.

    Soooooooooooooo, I decided to ask the SitePoint Family about this.

    All info appreciated.

    WP
    Webbing Along!!!

  2. #2
    Freelance Web Designer KeithMcL's Avatar
    Join Date
    Oct 1999
    Location
    Dublin, Ireland
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't believe having a / makes any difference. I think your talking about having links like this,

    <a href="index.html">link 1</a> or
    <a href="http://www.mydomain.com/index.html">link 2</a>

    There are some differences to the 2 above links, which i'm sure someone will post the answer, cause I can't remember

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by WP1

    <A HREF="presskit.html"> with NO slash

    OR

    <A HREF="/presskit.html"> with the FORWARD slash??
    Edited - because my answer was wrong!!!

    Correct:

    /presskit.html is an absolute path to the file "presskit.html" in the root directory.

    "presskit.html" is a relative path to the file in the current directory.
    Last edited by freakysid; Feb 21, 2001 at 12:48.

  4. #4
    SitePoint Zealot cokeman's Avatar
    Join Date
    Dec 2000
    Location
    So. California
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I remember reading about how having <a href="http://www.domain.com"> as opposed to <a href="http://www.domain.com/"> made a difference. I believe the first one actually causes two requests for the index page, while the second one (because of the trailing slash) only uses one request. I don't think having the slash (or not) in front of the file name affects anything (other than the slash requiring the file to be at the web root, while the no-slash file can be a relative location)..

  5. #5
    ********* Addict WP1's Avatar
    Join Date
    Aug 2000
    Location
    New York , USA
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for responding everyone!!!

    My question would now be how the original code I referred to would affect server time and load.

    Would writing the link code either way cause less or more stress on a server??

    When you refer to "relative path", do you mean relative to the directory. In other words, would relative path mean you are referring to another file somewhere within a directory on a website or anywhere within the entire site???

    WP
    Webbing Along!!!

  6. #6
    Don't get too close, I bite! Nicky's Avatar
    Join Date
    Jul 1999
    Location
    Lancashire, UK
    Posts
    8,277
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I think that a relative path WITHOUT using the domain name is probably more modular as it makes your site a lot easier to move around and even to change your domain name!

  7. #7
    ComDude CryingWolf's Avatar
    Join Date
    Dec 2000
    Location
    I don't know the cat drug it in!!!
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah the use of relative paths does make the site easier to move. The slash really doesn't make a difference in your case. I would just normally write things (if coding by hand without the slash) I do notice that the program I currently use (read lazy here) will set all relative paths using the slash but it does it like this:

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

    This is telling me that the page is telling the browser to start in the directory that you are all ready in.

    Really I use relative links on everything except on offsite links and files of course.

    Personally if I was to code by hand and use the slash I would use the ./directory/filename.html thing else it is just directory/filename.html or just filename.html for files in the same directory...

    Hope this helps

    Late

    P.S. the ./ means current directory
    body { background:#000000; color:#000000 }
    HEY, WHO TURNED OUT THE LIGHTS?!?
    Easy come easy go!!!
    CryingWolf


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
  •