HeadlinesBriefing favicon HeadlinesBriefing.com

Treating CSS as a Query Language: From Selectors to Logic

Hacker News •
×

A Hacker News thread explores the idea of turning CSS into a query‑oriented language, dubbed CSSLog. The proposal treats HTML elements as immutable “Things” and uses selectors to define sets, then applies rules that can modify those sets—adding classes or even generating markup—much like a programming language.

Supporters compare CSSLog to Datalog, a logic‑programming system where facts and rules describe relationships. By allowing selectors to add classes and propagate state recursively, CSSLog could express transitive conditions such as “an element is effectively dark if it inherits a dark theme without an intervening light theme,” a pattern regular CSS struggles to capture.

Critics warn that extending CSS with mutable operations blurs its original purpose of styling, risking complexity and unpredictable rendering. Nonetheless, the discussion highlights a broader trend: developers repurposing familiar web technologies for data‑driven UI logic, suggesting that future styling tools may incorporate more expressive, rule‑based capabilities.