Using external stylesheets with includes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mike6432
Forum Newbie
Posts: 3
Joined: Sun Aug 08, 2010 7:06 am

Using external stylesheets with includes

Post 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
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Using external stylesheets with includes

Post by JakeJ »

Are you calling the css file BEFORE the include?
mike6432
Forum Newbie
Posts: 3
Joined: Sun Aug 08, 2010 7:06 am

Re: Using external stylesheets with includes

Post 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.
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Using external stylesheets with includes

Post 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.
mike6432
Forum Newbie
Posts: 3
Joined: Sun Aug 08, 2010 7:06 am

Re: Using external stylesheets with includes

Post 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.
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Using external stylesheets with includes

Post 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.
Post Reply