The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to make Dynamic CSS??

  • This topic is empty.
Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
  • #242428
    Edison Lazar

    when run my html page it shows all source of my page


    I don’t have much experience on this subject, but it looks like you need to modify your .htaccess file to get this to work. Did you do that step?

    What’s your use case? If you just want variables in your css, you’d probably be better off just using SCSS or the like.


    You don’t have to modify your .htaccess. unless you might be using a WordPress site.

    I did this and it worked fine (not using a WordPress site); but it is a very complicated system.

    Most of the answers are already given, and you have to follow them completely.

    This is what I had done:

    Link to your style.php in the HTML page HEAD:
    <link rel=”stylesheet” type=”text/css” href=”css/style.php”

    In your style.php you have to convert BACK to CSS (this should be your first lines in your style sheet):

    header(“Content-type: text/css; charset: UTF-8”);
    — Now set your variables–
    $variable1= “whatever”;

    Now you set your normal CSS, but you now can use the variables; also, you must declare the php as you would normally

    #thisID{color:<?php echo $variable;?>; }
    .thisClass{background:<?php echo $variable;?>;


    I reverted back to normal CSS because it increased my code; my intention was to reduce the code.

Viewing 3 posts - 16 through 18 (of 18 total)
  • The forum ‘CSS’ is closed to new topics and replies.