PDA

View Full Version : Using CSS with PHP


Sir Penguin
23-02-2005, 05:50:16
I'm just using PHP to save on content replication. All the PHP code I'm using is
<?php

include ("header.inc") ;

?>
where header.inc holds the header of the HTML pages I'm generating. That code is placed in index.php. In that header, I have the following code (as well as other code):

<link rel="stylesheet" type="text/css" media="screen" title="style" href="style.css" />
or
<style type="text/css" title="style">
@import "style.css";
</style>
Neither of those work. I have also placed the stylesheet include code in the index.php file, and it still doesn't work.

What does work is if I copy and paste the information from style.css into the tags in header.inc, as in:

<body style="font: 16pt georgia; color: #000000; margin: 0px;">

It also works as a straight HTML file--the code generated by the PHP interpreter includes style.css properly when copied and pasted into another HTML document. Is this a problem with UVic's PHP interpreter, or am I doing something wrong? Isn't style inclusion a browser thing, not a server thing?

SP

Sir Penguin
23-02-2005, 05:53:52
OK, I just hardcoded the contents of style.css into the <style> tags of header.inc. Duh, it works. So, why didn't PHP like the style to be in an external document?

SP

LoD
23-02-2005, 11:45:19
The problem with CSS is that most browsers are very lazy when refreshing it. So be sure to clear your browser cache each time you test. From what I see you were doing everything correctly. And yes, style inclusion is a browser thing.

Nav
23-02-2005, 14:04:40
I had real problems including a css file via a script. A colleague of mine didnt seem to be able to refresh it at all! Had to include the contents into the actual file.