Design Question

Come to think of it… it is not a design question as much as format…

Pretty basic question.
I have my folder on my web server, where my index.html is located (named A), and then I have a subfolder for a php file I was making (named B).

Now normally when you are in A and you want to link to something like your photos which are located in another folder (named C) you would say: FolderC/image.jpg… say i am in folder B (which remember is a sub-folder of A), how do I link back to it? Would I do FolderA/item?

I figured it out btw… it is, …/filename

Yup!

Glad you figured it out and you can find more info here.

Just make sure you don’t end up with links like <a href=“http://www.sitepoint.com/forums/resource/”></a> as this leads to bad coding practices. The only time I reference a …/ would be when using PHP includes, never in a website structure (search engines can have issues with this).

I have also used the …/ to get to the root directory in CSS when referencing and image.

I would never reference the root in CSS that way. ALWAYS reference the root as an absolute URL starting with a /images_directory/file.jpg. One other problem with using …/ is if you every implement things like mod rewrites this can cause a debugging nightmare.

Sometimes you don’t have any choice. I do development in an application that produces multi-directory photo album pages. But within a given album, there’s typically just one CSS file, at the album’s root level. The application has absolutely no idea where you’re going to host that album. So, it doesn’t know what the absolute URL for the CSS file will be, nor can it count on the album residing at the root level of your hosting account (you might plant it at http://www.example.com/personal/travels/myalbum). So, references to the CSS file might be …/…/…/styles.css (at a third-level subdirectory, for example, like myalbum/europe/italy/2009). A relative URL is the only way to keep the entire album “portable,” i.e., it can be hosted anywhere.

A properly-formed mod rewrite shouldn’t have any problems with this, but yes, if you get careless, weird things could happen!

I always try to keep all my CSS in one central directory at a fixed location off of the root of the website, if I had a scenario with multiple css sheets for each album I’d keep them in the same sub directory off of the CSS directory.

To repeat, this is an application that’s running on your PC/Mac, and building the pages in a certain structure. It has no idea where the end product is going to land. It can’t refer to some “central directory,” about which it knows nothing. It knows only about what it is creating, and it must use relative URL’s to do that.

(Unfortunately it looks like VBulletin has stuffed up the example link you gave in that “trying to be helpful but failing” technique it uses so often. But I think we’ve got the picture of what you meant from the rest of the text)

I don’t see why it leads to bad coding practices. Sometimes you will have a folder structure that is several layers deep. Depending on the nature of your site, it may be much easier to manage it if you store things in that way than having fewer folders but each having many more pages in. So sometimes a link to …/ may not be a link to the root, it may be a link to the parent folder - in which case, I’d say it is better to retain it as …/ rather than give a root reference that then has to include the folder name. If you do it that way, your code is less flexible and less reusable, you’re more likely to end up with a link to the wrong folder at the next level up.

As for search engines - nope. Search engines, like any other browser with a person using it, can and will correctly and unambiguously parse any correctly formed hyperlink, whether it’s a relative reference, a root reference or an absolute reference. Search engines don’t have any problems coping with relative links incorporating …/

In the case of well developed software its all irrelevant since all request are normally routed through a single entry point using GET parameters to determine the content that will be shown.

@Stevie oddz said it right with the word well developed. But not everyone develops at a high level. When I was the Director of SEO Services of Beanstalk SEO I analyzed hundreds of websites and I couldn’t the number of times people used the …/ references wrong. Personally I don’t use them at all to avoid potential issues.