Archive

Posts Tagged ‘m4’

m4 Macros and CSS

December 18th, 2010 5 comments

I’m certainly not the first person to consider this, but it’s a simple enough technique for managing CSS that it bears repeating.

The problem: your CSS has a bunch of constants hard-coded in it all over the place, because CSS doesn’t support the concept of variables.

Perhaps the original theme color was #1122ff, and so you have CSS like this, where the string “1122ff” appears about 8 million times in your various CSS files:

#somediv {
    background-color: #1122ff;
}

.othertext {
    color: #1122ff;
}

But then you find out that the new theme color is going to be #2211ff and can you please change it. Sure there’s search-and-replace, but there might be false positives, and it’s not easy to verify that everything replaced well.

But there is a better way!

Read more…

Share
Categories: Programmer Tags: , ,