Simple Color Constants For CSS

Ok So CSS doesn’t have a way to declare constants.

But yet you always want a set of constant colors?

I discovered a simple method which is manual but works.

All you do is :


#116611/*text*/
#1A801A/*border*/
#FFFFFF/*high-text*/
#9966FF/*high-bg*/
#FFFFFF/*page-bg*/

Then whenever you reference a color:

div#sitemast { color:#116611/*text*/; }

now all you have to do if you want to change a color globally is use your editor to do a global search and replace.

This is more efficient than simply S/R on the hex value – what if you have 2 types of element which are the same color in one scheme but not another?

Next I would love to write a simple plugin for intellij which does this for you!

Share