PDA

View Full Version : .CSS help


doune
08-15-2006, 01:26 AM
Why does my .css page only affects my index.php but not my other pages.

This is why I have in the <head></head> of all my pages:

<link href="code.css" rel="stylesheet" type="text/css">


My code.css is in the public_html, so is my Index.php.

All my other pages are in different directories, could this be the problem?

Do I have to make changes in the code below to the pages that are in different categories?

<link href="chart.css" rel="stylesheet" type="text/css">

_Aerospace_Eng_
08-15-2006, 01:28 AM
Try this instead
<link href="/code.css" rel="stylesheet" type="text/css">
Now all of your other pages will look for the CSS in the root of your site. What was happening is your pages couldn't find the stylesheet mentioned in the directory that your pages were in.

doune
08-15-2006, 01:58 AM
Thanks, can please explain what is the difference between a code with or without ‘/’

I always thought it was a matter of preference to have a / at the beginning or not, clearly I was wrong.

_Aerospace_Eng_
08-15-2006, 02:28 AM
The / at the beginning tells the web page to look for the file at the root of the site rather than in the same folder. This is useful when you have many pages in subdirectories.

doune
08-15-2006, 03:13 AM
The / at the beginning tells the web page to look for the file at the root of the site rather than in the same folder. This is useful when you have many pages in subdirectories.

Thanks,

And what does a code without the "/" at the beginning mean?

_Aerospace_Eng_
08-15-2006, 03:15 AM
Are you not reading the posts I have made or what? I've already answered this question. Without it which is what you had before the page looks for the file in the same directory.

rmedek
08-15-2006, 03:19 AM
without the "/" it looks in the same directory.

If the page you're on is domain.com/about/history/index.php, and you're linking to "css/style.css" for example…

css/style.css — domain.com/about/history/css/style.css
/css/style.css — domain.com/css/style.css
../css/style.css — domain.com/about/css/style.css

doune
08-15-2006, 03:23 AM
But it's not working that’s why I asked the questions twice just to make sure, I tried with or without and it has no affect on any of the dynamic php (i.e, homepage.php, dog.php, etc...) pages other than the index.php itself.

Why is it not working? :(

_Aerospace_Eng_
08-15-2006, 03:24 AM
How are we supposed to know why its not working when you haven't provided a link to the page?