CSS has nothing to do with functional programming. You are correct that neither an OO or functional mindset is helpful - but that doesn't mean that CSS isn't "fit for purpose".
A rules engine is all about providing an alternative computational model. Instead of the usual imperative model, which consists of commands in sequence with conditionals and loops ... rules, each of which has a condition and an action - simplistically you can think of it as a bunch of if-then statements.
i.e.:
Selector lists act as conditions.
Property lists act as actions.
Specificity and source order govern rule priority.
So in writing CSS you are composing rules for a domain specific rules engine (the layout engine) which drives the visual design of the page.
To understand CSS better I'd look into the Inverted Triangle CSS architecture. It makes clear that CSS works from the top down specifying rules that specify the global look and feel - then adding more rules where necessary to override the global settings for more local requirements (Google's web.dev uses it).
From what I can see, people do far more with CSS today than styling the corners of a button. If you where true, why did they invent the shadow dom then?
The more people start to create applications on the web, they will need state dependent styling. Yes, you are right, CSS features a top down approach that does not fit to this task.
.
While the theory was good on paper, the practice is that only ads and ads providers somehow benefit from this technology
they will need state dependent styling. Yes, you are right, CSS features a top down approach that does not fit to this task.
On the simplest level that is accomplished by adding and removing CSS classes but even techniques like quantity queries are available. So the "component" has control of the class names on the DOM elements to reflect visual state but the top-down styles get to actually act on it - because layout and visual design has to be orchestrated as a whole.
And Andrea Giammarchi has been at it (the web) since before 2006 - and he will keep at it for the foreseeable future. Got to admire that but if that's what it takes …
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
CSS has nothing to do with functional programming. You are correct that neither an OO or functional mindset is helpful - but that doesn't mean that CSS isn't "fit for purpose".
Martin Fowler Bliki: RulesEngine:
i.e.:
So in writing CSS you are composing rules for a domain specific rules engine (the layout engine) which drives the visual design of the page.
To understand CSS better I'd look into the Inverted Triangle CSS architecture. It makes clear that CSS works from the top down specifying rules that specify the global look and feel - then adding more rules where necessary to override the global settings for more local requirements (Google's web.dev uses it).
CSS Is Certainly Global And That’s Exactly The Point
The entire CSS-in-JS and styled-components movement fails to account for the fact that layout, visual styling and CSS works top-down - not bottom-up.
Keith J. Grant:
The problem is that people are familiar and comfortable with component approaches even when they are a "square peg in a round hole".
No - it's just that many people don't want to but in the effort to
and rather preserve at all costs the ways which they are already comfortable working with.
Front end and back end
Static page performance is the gold standard
From what I can see, people do far more with CSS today than styling the corners of a button. If you where true, why did they invent the shadow dom then?
The more people start to create applications on the web, they will need state dependent styling. Yes, you are right, CSS features a top down approach that does not fit to this task.
.
About Web Components - Why Shadow DOM?:
On the simplest level that is accomplished by adding and removing CSS classes but even techniques like quantity queries are available. So the "component" has control of the class names on the DOM elements to reflect visual state but the top-down styles get to actually act on it - because layout and visual design has to be orchestrated as a whole.
"We all love the Web, but in stories like this one, it feels like the Web doesn’t really love us back … or not as much"
And Andrea Giammarchi has been at it (the web) since before 2006 - and he will keep at it for the foreseeable future. Got to admire that but if that's what it takes …