Forum Moderators: coopster

Message Too Old, No Replies

CSS in subdirectory files not applying

         

zulubanshee

5:19 am on Dec 11, 2008 (gmt 0)

10+ Year Member



I've worked on this for hours and cannot figure it out. I have my css file in a directory called "styles" in the root directory. Within it is the style sheet called "styles.css". I created a header file called "header,..php", which is in the root directory which calls the css (just spelling everything out to make sure we're all on the right page). Everything is ok for files in the root directory.

But I have other files, in subdirectories, that use header.php. I can get the pages to load ok, ie no errors, the page source shows everything is ok, but the css is not applying. It's just the html.

Any help would be appreciated.

supermanjnk

1:34 pm on Dec 11, 2008 (gmt 0)

10+ Year Member



What is the path you are using to bring in the CSS? can you post a snippet of your header that contains the link to the stylesheet?

zulubanshee

6:02 pm on Dec 11, 2008 (gmt 0)

10+ Year Member




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Free Movie Links</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="styles/styles.css" rel="stylesheet" type="text/css" />
</head>

Again, this works for any files in the root, but not in subdirectories

Alcoholico

6:53 pm on Dec 11, 2008 (gmt 0)

10+ Year Member



If styles/styles.css is on the root of your domain changing

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

to

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

will do the trick. Also do not forget giving absolute paths to your images inside the CSS file, for instance if you are calling an images in your images dir, use "/images/image.png" instead of "images/image.png", "/" at the start represents the root dir of your server/domain. Of course you could also use your full URL:

<link href="http://example.com/styles/styles.css" rel="stylesheet" type="text/css" />

zulubanshee

7:23 pm on Dec 11, 2008 (gmt 0)

10+ Year Member




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

i tried that before and it even breaks the index.php in the root.

zulubanshee

6:24 am on Dec 12, 2008 (gmt 0)

10+ Year Member



ohwell, i tried it again just now and it worked fine. thanks