Page 1 of 1

Using external stylesheets with includes

Posted: Sun Aug 08, 2010 7:10 am
by mike6432
Hi,

I'm setting up some PHP pages and I'm having a problem where my php include file is not rendering an external stylesheet.

I have ...

index.php in a root folder, this calls on a header area include("topHeader.php");

and I have the directory structure

images, styles and includes

inside the includes folder, I have topHeader.php

When I call the include in index.php, the content shows up fine, but the CSS is not being rendered. Now I have a stylesheet being linked from the index.php page, in the head.

So what am I missing when using css with an include file?

Thanks

Re: Using external stylesheets with includes

Posted: Sun Aug 08, 2010 4:16 pm
by JakeJ
Are you calling the css file BEFORE the include?

Re: Using external stylesheets with includes

Posted: Mon Aug 09, 2010 6:56 am
by mike6432
Yes, I am calling the stylesheet in the head tags of the main page that's calling the include. Then in the body I have the include. So the stylesheet should be rendering before the include gets picked up.

Re: Using external stylesheets with includes

Posted: Mon Aug 09, 2010 8:01 am
by JakeJ
Ok. let's say you have three files:
style.css
index.php
include.php

On index.php, you reference the style sheet first. Then include.php.

My next question then is this. Do you have elements on index.php before and/or after the include that are rendering properly?

Also, is it possible you have the path to your css file wrong?

Post some code and I'll see what I can do. But probably not until this afternoon.

Re: Using external stylesheets with includes

Posted: Mon Aug 09, 2010 10:06 am
by mike6432
OK, not php related. I deleted and retyped the link to the css and it works now, which is odd, considering I had the same exact code calling the CSS.

Sorry for wasting your time, thanks for your help though.

Re: Using external stylesheets with includes

Posted: Mon Aug 09, 2010 2:38 pm
by JakeJ
Nah, it wasn't a waste of time. I've had to do the same thing many times. SOMETHING was different.

Last night I spent two hours troubleshooting a jQuery form when it turns out I was just missing a pound sign. I guess that's how programming goes.