CSS is not Turing Complete

As more and more abilities are shoved into CSS (or into various preprocessors of CSS like Sass/SCSS | Less) you wonder how far CSS3 is from being its own programming language. The answer is: it's still not a programming language. And in fact it's not even a really crappy one, as it is not shown to itself be Turing complete. (Except for some variants of Internet Explorer which allow you to use expressions as CSS values, but this is not supported and highly recommended against for performance reasons.)

You may recall from theoretical computer science classes that Alan Turing (you may know of him from the recent movie The Imitation Game, 8.1/10 on IMDB) conjectured this notion of computing/computable and that any modern computer we see or can invision today is just as powerful but no more powerful than this besides performance (but the theoretical Turing computer is also unlimited in memory, which real computers haven't figured out yet). Likewise, all programming languages have equivalent Turing machines meaning they are no more or less capable than each other in what they can compute. In real life, it means there are mainly things that are programming languages and which can do amazing and unpredictable things, and then there is everything else which is basically predictable in their outputs if any.

JavaScript is a programming language and is the only one which browsers understand (there are things like Brython which let you write Python code to run in browsers but it works by including a Python interpreter written in JavaScript which does magic on the Python code). The other thing besides HTML which browsers understand is CSS. JavaScript allows the World Wide Web to be the magically interactive and thing it is today and to be more than just content/information. We wouldn't have this with just HTML and CSS. But there are people saying it would be possible, in theory!

(There are defined languages which are used in programming which may not be thought of as general programming languages and which are not Turing complete. E.g. regular expressions.)

There was a guy who "proved" that CSS is Turing complete. He showed an implementation of "Rule 110" in CSS3 + HTML. Rule 110 is a definition of a cellular automaton (the topic of which Stephen Wolfram wrote about for 1000s of pages in his controversial book 'A New Kind of Science' - of which I have a signed copy if anybody's interested). Anyways, others had previously shown that Rule 110 itself was Turing complete and so an implementation of it must also be Turing complete. The implementation depends on user input to click or hit a key to cause the "machine" to step through each iteration of processing. So it stops being a very good computer right after making its first move.

So if you are wondering if CSS is equivalent in the basic type of computing ability as every other programming language, the answer is 'no'. Because programming languages like JavaScript don't require you to click a million times before a simple expression can be calculated.

Other things that are considered Turing complete:

  • C++ templates processed at compile time are themselves able to compute anything.
  • People have made real computers in Minecraft. But Magic the Gathering is also apparently able to compute anything.