Comment by berkes

2 years ago

Interesting to think about the implications of a non-cascading system.

First that comes to mind, is how in OOP we have this idea of "composition over inheritance". Would composable style sheets be better? IDK.

Second issue I see is that, by all definitions, browsers come with a default style. What would "No style" even be? Invisible? Or maybe a very basic default? And would that be readable at all? And how do we the override these defaults? Would the existence of any custom styles immediately disable any base styles?

Lots of issues that are mostly "solved" with cascading. But which would need (a) solution(s) without cascading.

I still like exploring the idea, but the more I dive down that rabbit hole, the more I think that actually cascading is a rather elegant solution.

And, as with OOP inheritance, it's up to us to keep it sane. I've always managed to keep my cascading max three levels: browser, basis.css, custom.css. and in neither basis nor custom, do I have inheritance (cascading) chains.

I've even used a Linter to enforce this, years ago. Cannot find it anymore, sadly.