Forum Moderators: not2easy
I am new to CSS so excuse the lame questions. Thanks.
Couldnt get it into the .css file so the next best thing was inline styles:
<table style="background-color:<%=G_BGCOLOR%>">
Its not a great solution , a macro would be much nicer but I couldnt figure out how.
This method is used in many languages (C pascal etc )
at the top of the file you have stuff like
#define Brown #804040
#define MyEmail billG@microsoft.com
and in the source you have something like.....
Background-color = Brown;
...
...
email = MyEmail;
These may occur many times within the file. The advantage of a macro is that I do not have to find them, just change the definition at the top of the file (or included file) and the preprocessor or compiler does the rest for me. It is neat & tidy.
I am not sure yet how sophisticated this CSS stuff is, I used to be a C,C++ programmer and old habits die hard.
I will probably just move all things that I might want to change from time to time (like aesthetics) to a separate file like color.css and have the definitions there. At least they will be in one place.
If you are really keen on coding like this then you could write your CSS in PHP. Like this...
<?php
header( 'Content-Type: text/css' );
define( 'BROWN', '#804040' );
define( 'PINK', '#daa');
?>
.myclass {
font: <?php echo BROWN?>;
background: <?php echo PINK?>;
border: 1px solid <?php echo BROWN?>;
}
and then link to it as an external stylesheet in the normal way..
<link rel="stylesheet" type="text/css" href="styles.php"> To my mind this is a bit too clunky to use effectively so I can't really recommend it - but if you are already using a php stylesheet for other reasons (e.g. browser switching) then it might be useful to you.