[thelist] strategies for global css in a local site - abs/rel paths

Sam sam at sam-i-am.com
Tue Mar 5 14:10:00 CST 2002


I'd like to hear your thoughts and experiences with this.
As you (should) know, relative paths in a globally LINKed stylesheet are
normally relative to the location of the css file, however are taken as
relative to the document location in NN4.

Ordinarily this isn't a huge problem as I can use absolute paths. So I
might reference a background image so:
	background-image: url(/images/bg.gif);
.. and both IE and NN are happy.

Now, however, I have to come up with a strategy that works for a large,
deep site that must be browseable locally (cd-rom, desktop, whatever) as
well as via the server.

The directory tree might get as deep as 5 or 6 levels and the number of
paths likely to occur in my css are unknown right now. I think I have 2
choices:

1) duplicate the css in every directory, and LINK it relatively: [link
href="style.css"].
paths to images referenced in the css would be relative from that
directory eg url(../../../images/bg.gif);

2) duplicate the referenced images into each directory, leaving the css
at the root. So if my document is at /dir/subdir/file.html the link to
the css would be ../../style.css, and all paths in the css would be
like: url(images/bg.gif). NN4 would use /dir/subdir/images/bg.gif and
IE,NN6 etc. would use /images/bg.gif.

obviously neither of these options is ideal. Am I missing a third,
slightly-more-ideal solution? This site is likely to be zip and emailed,
burnt to cd etc. so I have no control over where the user choices to
locate it. And though I've not yet made the css I can almost guarantee
there will be background images used (the design will be provided, and I
have some but not much influence over it)

thanks for any ideas,

Sam



More information about the thelist mailing list