RE: Understanding CSS path references (was Re: Problems with NN 4.7)

by George Nielsen <genie(at)postone.com>

 Date:  Fri, 22 Feb 2002 11:27:56 +0100
 To:  hwg-techniques(at)mail.hwg.org
 Cc:  Jay Smith <jay(at)JaySmith.com>
 In-Reply-To: 
  todo: View Thread, Original
Hi Jay,

Thank you very much for the thorough explanation.

Using FrontPage I tried the different dot and slash combinations, and I 
also included the word shared. Whatever I did the HTML page could not see 
the style sheet. Only when I left it as "Personal.css" could the stylesheet 
be seen. I saved and looked at it with Internet Explorer, and the result 
was the same. Therefore it could hardly have been a problem with FrontPage.

All my files are in folders except for index.html. All other HTML files are 
in the folder PersonalFiles, where one also finds the stylesheet 
Personal.css. The file index.html is a frames page. When accessing my 
Website this file points to four differnet HTML files in the folder 
PersonalFiles (you do notice that I removed the space in the name). These 
HTML files look for the stylesheet Personal.css in the same folder, 
PersonalFiles.

When using Internet Explorer they find the stylesheet, but when using 
Netscape Navigator they do not. However, the HTML files in the folder 
PersonalFiles do find the stylesheet Personal.css when it is alongside the 
file index.html, outside all folders, even though I do not use any dots or 
slashes or the word shared. As the stylesheet and the HTML file are in the 
same folder then Netscape should be able to find it even though I do not 
use dots or slashes.

George

>Date: Thu, 21 Feb 2002 16:52:10 -0500
>From: Jay Smith <jay(at)JaySmith.com>
>Subject: RE: Understanding CSS path references (was Re: Problems with NN 4.7)
>
>Hi George,
>
>You can put the CSS file wherever you want (inside the directories
>visible to the web server).  However, you gotta tell the browser where
>it is. You told the browser, but you told it somewhere it was not.
>
>Your possibilities are:
>
>RELATIVE REFERENCES
>Works relative to your HTML file location.  This is easy and quick,
>but if you move either the HTML or CSS file to another LEVEL in your
>directory structure, then you break the link.
>
>"Personal.css"  = same directory as the page that calls it
>www.YourDomain.com/subdirectory/MyFile.html
>www.YourDomain.com/subdirectory/Personal.css
>
>"../Personal.css"  = directory above the page that calls it
>www.YourDomain.com/subdirectory/MyFile.html
>www.YourDomain.com/Personal.css
>
>"../../Personal.css"  = two directories above the page that calls it.
>www.YourDomain.com/subdirectory/subdir2/MyFile.html
>www.YourDomain.com/Personal.css
>
>"../shared/Personal.css" = one directory above, then down into the
>shared directory that is at an equal level with the subdirectory the
>HTML file is in.
>www.YourDomain.com/subdirectory/MyFile.html
>www.YourDomain.com/shared/Personal.css
>
>
>ABSOLUTE (SERVER ROOT) REFERENCES
>This is much more reliable if your site changes much.  However, your
>web server must be configured to do this.  It is easy to configure if
>you are familiar with such things.  IF YOU USE ABSOLUTE (SERVER ROOT)
>REFERENCES, THEN YOU CAN MOVE YOUR HTML FILES AT WILL AND YOU WILL NOT
>BREAK THE LINK TO THE CSS.  NOTE THAT YOU CAN ALSO USE THIS SAME
>METHOD OF ADDRESSING IMAGES AND ANY OTHER LINKS THAT ARE WITHIN THE
>SAME SERVER ROOT.
>
>"/Personal.css"  = css file is located in the server root directory.
>This would be www.YourDomain.com/Personal.css
>
>"/shared/Personal.css" = = css file is located in the shared
>subdirectory one level down from the server root directory.  This
>would be www.YourDomain.com/shared/Personal.css
>
>Have fun.
>
>Jay

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA