Forum Moderators: not2easy

Message Too Old, No Replies

Scripting (PHP) in external CSS files

Can it be done?

         

benlieb

4:51 am on Nov 9, 2004 (gmt 0)

10+ Year Member



I've frequently wanted to use some form of variable in my external CSS files. For example in a given color scheme you may use one color in 20 places, then want to change that color everywhere quickly.

Alas, I don't think scripting is allowed in CSS files, or is there some way I don't know of?

I've thought of just putting the CSS in the page itself, thereby getting PHP in on the action. But this seems like a step in the wrong direction.

jetboy_70

10:37 am on Nov 9, 2004 (gmt 0)

10+ Year Member



Yes. Easily. All explained here: :)

[webmasterworld.com ]

dcrombie

10:38 am on Nov 9, 2004 (gmt 0)



Your options are:

a) configure your site so .css files are parsed with PHP;
b) write the relevant CSS code in-line using PHP; or
c) use PHP to include alternate style-sheets.

You don't need to include ALL the CSS code in-line for (b) - just the sections you want to make dynamic.

DrDoc

5:19 pm on Nov 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or, simply point to a .php file instead of .css