Skip to content
Tech News
← Back to articles

CSS as a Query Language

read original get CSS Query Language Book → more articles
Why This Matters

Exploring CSS as a query language opens new possibilities for leveraging a familiar syntax beyond web layout, potentially enabling innovative tools and workflows in the tech industry. While unconventional, this approach highlights CSS's versatility and could inspire more integrated or streamlined development processes for both developers and consumers.

Key Takeaways

IN which we investigate using CSS as a query language, or even a general purpose programming language, to do things other than lay out web pages in a browser.

Question: Why in God’s good name would you do that? CSS is infamously confusing. And better query languages exist, right? Such as SQL, which famously doesn’t have problems.

Answer: Because it’s there.

The basic principles of CSS look like this.

1. There are Things

“Things” are “domain entities”, or “atoms”, or “facts”. They exist outside of CSS – from CSS’s perspective, they’re just already and always there.

Such as:

<h1> Hello, World! </h1> <a href= "example.com" > This is a link </a> <div class= "awesome" data-custom-attribute= "foo" > <div id= "child" > This div is inside another one! </div> </div>

Specifically, here, Things are HTML elements.

2. We can Describe Sets of Things

... continue reading