How to use base href?

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

to remove all ads.
  1. braveandplucky

    braveandplucky New Member

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

    Edited to add: I thought I figured out, based on the end of this ( tutorial, to use ../ at the beginning of these links to get them to route back to parent or grandparent pages. However, this tutorial ( 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, when 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

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

    if you have and your css is located at

    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.

  3. joe

    joe New Member

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

    edjones8 New Member

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

    gkumar New Member


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

    gkumar New Member

    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

    I have never heard of or used <base href=""> ??

Share This Page