The article maps CSS selector semantics onto Datalog logic programming, proposing “CSSLog” with fixpoint evaluation to express recursive, transitive queries CSS cannot.
Key Takeaways
CSS selectors already behave like Datalog rule bodies: selectors match sets of elements the same way Datalog variables match tuples in a relation.
CSS declarations are the head of a logic rule; div.awesome { color: red } is color(X, red) :- div(X), class(X, awesome) written backwards.
CSS cannot express recursive/transitive relationships – the “effectively-dark theme ancestor” example requires writing an unbounded series of override rules.
CSSLog adds fixpoint evaluation: rules fire repeatedly, propagating derived facts (classes, attributes) until the known set stops growing, mirroring naive Datalog evaluation.
Datalog’s fixpoint approach is what WITH RECURSIVE in SQL approximates – and what CSS would need to support genuinely transitive style inheritance.
Hacker News Comment Review
One commenter challenged the motivating scenario, noting CSS :has() already allows selecting parents conditionally on child state – narrowing but not eliminating the gap the article describes.
No broader technical debate yet on fixpoint termination guarantees, specificity conflicts under recursive rules, or browser implementation feasibility.
Notable Comments
@efortis: Demonstrates pre:has(> code) { padding: 0 } as a working counterexample, questioning whether CSSLog’s added complexity is justified for the dark-mode nesting case.