Web Design Forum  
 
Go Back   Web Design Forum > Web and Graphic Design > Web Design

Reply
 
LinkBack Thread Tools Display Modes
Old 08-17-2008, 03:04 AM   #1 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 12
Default How to use base href?

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 by braveandplucky; 08-17-2008 at 03:44 AM.
braveandplucky is offline   Reply With Quote
Old 08-18-2008, 01:26 AM   #2 (permalink)
Moderator
 
jnjc's Avatar
 
Join Date: Jun 2008
Posts: 365
Default

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
jnjc is offline   Reply With Quote
Old 08-18-2008, 02:03 AM   #3 (permalink)
joe
Bronze Member
 
Join Date: Aug 2008
Location: Dallas, Tx
Posts: 83
Default

Quote:
Originally Posted by jnjc View Post
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
Jnjc's right. this should do what you need.
joe is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:09 AM.


Computer Forum - TechZine - Webpage Design

 
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.