Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

href syntax in <link> for CSS

Sorry for the elementary question. I'm trying to set up a template containing a linked external CSS file. The template is intended to serve for content at various directory levels, e.g., doc root, Articles, etc.

My problem is how to specify the href so that I can preview the content and have the external CSS  file be found and used.

As I understand it, I should simply be able to do something like <link ... href="/styles/myStylesheet.css" ... /> and be done. Assuming of course that the styles directory is one down from the document root, i.e.,  the leading slash stands for the document root.

This doesn't happen with CD, at least in the document editor preview. Admitedly, I'm not a guru by any means so I'd appreciate pointers to the solution, if it exists.

Thanks.                ...edN

ed nixon
Friday, June 13, 2003

In the head block, do this:
<link rel="stylesheet" type="text/css" href="thesheet.css">

Troy King
Friday, June 13, 2003

Thanks. I don't think I was clear.

If I'm not mistaken, your example href, i.e., href="thesheet.css" will work if the stylesheet is located in the same directory as the file containing the <link> element.

It will not work if the stylesheet is located in, say, /styles off the document root and the <link> element file is located in, say, the document root or alternatively in any other directory under the docroot except /styles.

If I'm right, yours is not the solution I need. I want to locate my stylesheets in, say, /styles, a subdirectory under the document root and I want to locate my html source anywhere other than styles at or under the document root. And I want to set up a template that contains the <link> element, specified such that it doesn't have to be changed in order to find the CSS depending on the html file's location.

Is this clearer? Thanks again.

ed nixon
Friday, June 13, 2003

I may not understand either but if your style sheet is in your .cty file, just paste the magic name of your style tag:

<link rel="stylesheet" type="text/css" href="past-the-magic-name-here">

Friday, June 13, 2003

That's got it! Thanks.

Does that magic name thingy keep track of its own location? In other words, if I decide all of a sudden to rename my /styles folder to /css in the document tree, will the template still be looking for and finding the same href/file? Presumably this is the case with all magic names?

Thanks for your help.                    ...edN

ed nixon
Friday, June 13, 2003

That's the good thing about magic names. CityDesk creates the link to wherever the file is no matter where you are on the site.

The "hard coded" alternate would look like this:


where / is the root of your website -

The Architect
Friday, June 13, 2003

Yes, Ed, that's the great thing about magic names: you can move them around without breaking the links.

David Burch
Friday, June 13, 2003

*  Recent Topics

*  Fog Creek Home