Parsing CSS

This article was written in 2016. It might or it might not be outdated. And it could be that the layout breaks. If that’s the case please let me know.

I remember the first time I wrote some JavaScript I was very, very disappointed in how stupid computers are. They only understand loops, ifs, and elses. That’s it. And if you type esle instead of else it doesn’t understand what you mean. On the other hand I was surprised that I was able to create wonderful stuff with just these ifs, elses and loops. Breaking a problem down to these building blocks made me understand the issue better. I had a similar aha-erlebnis while I was reading the part in this article about parsing CSS with JavaScript by supernerd Peter van der Zee.

I’ve been writing CSS for quite a long time, and I’ve been teaching it for a few years as well. But it never occurred to me to start explaining CSS with the @-rules. Maybe it’s not the best way to explain it to humans, but it is definitely interesting to understand what computers do with your CSS. They’re the ones that turn it into the stuff our visitors use.