April 24, 2026

When selectors start a flamewar

CSS as a Query Language

CSS as a search tool? Devs split between 'why' and 'why not'

TLDR: A writer suggests bending CSS, the language for styling websites, into a tool for searching and targeting data. The crowd splits: skeptics ask why when other tools exist, fans praise CSS’s readability, and others share jokes and real tools proving the idea already has legs.

What if the stuff you use to color web pages could also search them? A new think-piece dares to use CSS—the style language behind buttons and bold text—as a query language: describe sets of things, then do stuff to them, even beyond the browser. The author riffs on selectors, shows how combining them picks targets, then runs into the classic “dark mode nesting” headache: rules that work once, then collapse into a whack‑a‑mole of exceptions. The trollish answer to “Why do this?” is basically because it’s there, and the big brain tease is whether CSS could express deeper logic without melting into paradox.

Cue the comments. Skeptics roll in first: efortis asks what problem this solves and points out CSS can already react to children with the new :has trick. On the other side, k1m cheers that CSS selectors beat XPath (an XML path language) for readability, lamenting the missing “select by text” superpower. Nostalgia hits when duncanfwalker drops the tongue‑in‑cheek GraphQL‑CSS, while spookylukey goes practical with pyastgrep, which uses CSS‑style queries to search Python code. The vibe? Half “this is cursed,” half “wait, this could be useful,” with one perfectly minimalist verdict from securityTalent: “Nice.”

Key Points

  • The article explores using CSS as a query language beyond traditional styling purposes.
  • CSS selectors define sets of domain entities (e.g., HTML elements) and can be combined via intersection and hierarchical relations.
  • CSS rules apply declarations to selected sets, modifying properties like color and font size.
  • A major limitation is that CSS cannot select elements based on properties set by CSS (e.g., computed color), leading to logical issues.
  • A dark-mode theming example shows that handling nested dark/light contexts requires many ad hoc rules, exposing CSS’s limits for transitive, generalized logic.

Hottest takes

"Not sure I follow the scenario this would solve." — efortis
"I find CSS selectors a lot easier to write than XPath." — k1m
"can use CSS selectors as a query language for Python syntax" — spookylukey
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.