homepage Welcome to WebmasterWorld Guest from 54.166.123.2
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
external CSS - How do you specify css file using an absolute path?
How do you specify css file using an absolute path?
stivare




msg:3902012
 11:50 pm on Apr 27, 2009 (gmt 0)

Hi Friends,

I am new to CSS and HTML, so this might be a very trivial question. I have a directory named "htdocs/css", where I store all of .css files. Then I have various webpages "htdocs/dir-1/.../dir-n/index.html" spread all around in htdocs directory for different parts of the site. I want to link the each index file with respective .css file using an absolute path like
<LINK ....... href="$somevariable/css/example.css >

and not a relative path like

<LINK ....... href="../../css/example.css >

is there a way I can do it? Please let me know

Thanks
Su Ti

 

swa66




msg:3902018
 12:10 am on Apr 28, 2009 (gmt 0)

Presuming that htdocs directory is where your documentroot is.

Try:

in HTML:
<link rel="stylesheet" type="text/css" href="/css/example.css">
in xhtml:
<link rel="stylesheet" type="text/css" href="/css/example.css" />

Put that in your head section.

stivare




msg:3902372
 2:10 pm on Apr 28, 2009 (gmt 0)

Thanks SWA,

That worked beautifully. Really appreciate your quick responce.

Cheers
Su

AusQB




msg:3923773
 9:33 am on Jun 1, 2009 (gmt 0)

I have a similar problem.

I have a file head.php which contains all the links to css files and script files (basically everything that goes in the <head> tag).

If I include that file in two pages, one in the root folder and one in a subfolder, the one in the subfolder will not be referenced properly since the link to the css file is relative to the root folder:

<link type="text/css" src="css/style.css" />

Adding the '/' to the front of the filepath does not resolve the issue in this case.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved