DEV Community

Discussion on: Is CSS an Object-Oriented Programming Language?

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

The comic seemed to go unnoticed again but then became viral on the /r/ProgrammerHumor channel on Reddit (without the poster adding a source or attribution for it 😓).

Yea, that subreddit is an absolute shitshow of dunning-kruger enthusiasts who think chanting "all code is copied from stack-overflow" while standing in a circle wearing dark hoods is somehow funny and original. Not surprised they wouldn't bother linking to the original.

That being said, I strongly disagree with calling CSS an object-oriented language (or even a programming language at all, albeit with a much weaker opinion). It shares some concepts of OOP, but it lacks the most central one: Objects. At the end of the day, CSS only lets you define classes (as in, OOP classes, which correspond to selectors, not CSS classes) but not instantiate them (that's what HTML does). Adding HTML, you then still lack another essential aspect, which is message-passing; HTML+CSS objects exist, but they don't interact. They can old state, but they don't have any behaviour. Once you add JS to the mix, you do end up with a proper object-oriented system of sorts, where CSS and JS define the classes and HTML instantiates the objects, but that's not normally the way developers think about websites (which is a shame, because it's a very powerful mental model).