...

View Full Version : must stylesheets use the extension .css?



bazz
02-03-2005, 04:28 PM
Is there an alternative file extension, that can be used as a stylesheet?

I am thinking of something dynamic and wondered if stylesheets have to have a .css extension at all. If not then is there a list of alternatives.


Bazz

brothercake
02-03-2005, 04:32 PM
Any file can have any extension - it's all about the headers.

For example - a dynamic stylesheet could have the extension .php, and still work as a stylesheet, providing you send the right header at the top:


header("Content-type: text/css");

bazz
02-03-2005, 06:18 PM
cool, Thanks. :thumbsup:

Bazz

bradyj
02-03-2005, 06:48 PM
Where do you put the header information as you posted in the code? Just at the top of any page is fine?

mcdougals4all
02-03-2005, 06:55 PM
In php, at the very top before any whitespace:


<?
header("Content-Type: text/css");
header("Cache-control: private, no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); //Past date
header("Pragma: no-cache");
?>

I use a dynamic stylesheet for a styleswitcher, and in addition to the content type, had to add the extra stuff becuase Opera seemed to be caching it and wouldn't reflect changes made to the dynamic stylesheet.

bradyj
02-03-2005, 06:57 PM
Interesting... but wouldn't that defeat some of the full power of CSS (having to download a new style sheet each time)? The cache is half the fun sometimes:)

PS - thanks for the quick, useful response by the way:)

mcdougals4all
02-03-2005, 06:59 PM
If it's a large file you're right. But if you're just changing a few rules on the fly it can be handy.

brothercake
02-03-2005, 08:18 PM
I don't see any benefit in stopping it from caching. For your own development purposes, Shift + Relead is force-refresh in Opera. Users won't have a problem, because it's done once they see it.

mcdougals4all
02-03-2005, 09:44 PM
For your own development purposes, Shift + Relead is force-refresh in Opera. Users won't have a problem, because it's done once they see it.
I don't think I understand :confused:

I've been using a php styleswitcher (http://www.codingforums.com/showthread.php?t=43097) to switch between three small css files and Opera doesn't reflect the change unless stopping each from caching. This is happening when viewing off the server.

bazz
02-04-2005, 03:55 PM
Oh no-no no no no no I don't want to change the existing/familiar functioning of a stylesheet.
Edited for Gobbledegook!

Where I have made a single perl program that enables the creation and presentation of a series of different dining menus, I can determine that each will have its own menu-specific stylesheet.

But I want also, to enable the creation of a stylesheet through the browser so that colors and fonts etc can be altered to suit a specific menu style. Y'see the prog I am using creates flat files with no extension and I wanted to find out if such files could be used as css before I spent more time with this specific script.

Then I want to bring the functionality of eight cms systems together into one package by adding a CP.

I'm some distance off doing the GUI CP because I am overworked on creating and learning more perl programs. :rolleyes:

Bazz

gsnedders
02-04-2005, 08:05 PM
For my dynamic CSS at my blog, I've got styles in the head element, so the stylesheet remains the same all the time...

hemebond
02-04-2005, 09:33 PM
I don't think I understand :confused:

I've been using a php styleswitcher (http://www.codingforums.com/showthread.php?t=43097) to switch between three small css files and Opera doesn't reflect the change unless stopping each from caching. This is happening when viewing off the server.That's because according to the browser and the server, you're serving the same file. The idea behind alternate stylesheets is to have different stylesheets that are de/activated by the user. This supports caching. What you need to do is append a variable to the end of the URL
<link rel="stylesheet" href="mystyles.css?colour=blue" type="text/css" media="screen">Then you give it a URL with a different variable to change the style.

I'm fairly sure this works, though I've never bothered with it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum