How to use base href?

Discussion in 'Web Design' started by braveandplucky, Aug 17, 2008.

to remove all ads.
  1. braveandplucky

    braveandplucky New Member

    Messages:
    12
    This is the first time I've tackled complex subdirectories, and I'm trying to figure out how to get subdirectory pages to access css and image folders located in the main directory. What am I missing? When I put just "css/main.css" as a link in a child page, the browser looks for the css WITHIN the current (child) folder. Do I need to enter the full URL for those files? Suck.

    I thought that declaring the base href at the top of all pages might work (that is, using the base href of the main index page on ALL the subpages so that all links within those documents complete relative to the main URL rather than the current URL).

    However, I see it warned here (http://chrisjdavis.org/base-href) that base href is intended to declare the full current page ID, unique to each document. Which throws me back to the original problem of shorthand links being perceived by the browser as children to the current page. Grrr!

    This is all exacerbated by the fact that I don't have access to the client's ftp yet, so I can't use the correct URLs or anything, but couch it all in folders on my own site.

    Any help would be appreciated.
    Julia

    Edited to add: I thought I figured out, based on the end of this (http://webtips.dan.info/subdir.html) tutorial, to use ../ at the beginning of these links to get them to route back to parent or grandparent pages. However, this tutorial (http://www.drostdesigns.com/base-href-tag/) explicitly states DON'T DO THAT, about halfway down the page, recommending instead the complete link filepath, but without recommendation for how to keep the browser from appending incomplete links (such as contact.html) to the current URL (eg www.whaaaaa.com/spadoinkal/snikes), when www.whaaaaa.com/spadoinkal/snikes/contact.html doesn't exist. However, I would only be using the ../ and ../../ tricks in permanent frame navigation, so it seems that that would be fine.

    I'm sure by this point that I'm missing something very obvious.
     
    Last edited: Aug 17, 2008
  2. jnjc

    jnjc New Member

    Messages:
    493
    I am not 100% sure I understand what you are trying to achieve but I'll have a go anyway.

    if you have www.somedomain.com and your css is located at

    www.somedomain.com/css/myfile.css

    then to reference this file use "/css/myfile.css" the leading "/" will tell the browser that the path name is relative to the "root" directory of your site, rather than the current directory.

    HTH,
    JC
     
  3. joe

    joe New Member

    Messages:
    82
    Jnjc's right. this should do what you need.
     
  4. edjones8

    edjones8 New Member

    Messages:
    4
    Thanks for useful information.
    hyper reference coding is:
     
  5. gkumar

    gkumar New Member

    Messages:
    4
    Example

    Specify a base URL for all relative URLs on a page:
     
  6. gkumar

    gkumar New Member

    Messages:
    4
    Is it ok to use the <Base Href=> in HTML? basically, I'm taking framed pages from my clients and copying their source code to promote them on my web site. (These clients are aware of this)

    But do search engines like the <Base Href>?
     
  7. PixelPusher

    PixelPusher Super Moderator Staff Member

    Messages:
    1,077
    I have never heard of or used <base href=""> ??
     

Share This Page