Is CSS a Programming Language?
Had you asked the web development community five years ago if CSS was a programming language, they would have said no. If you had asked them two years ago, they would have also said no still. If you asked them today, they would probably still say no... but some may add a little asterisk beside their answer.
But still, CSS isn't a programming language. It needs to be able to "implement specific algorithms" to do that, and it can't.
Or can it?
CSS's calc() can implement and solve algorithms. By passing values into it, it can then spit out an answer. For example:
We can complicate it a bit further too:
I know what you're thinking. Just because CSS can do basic math problems now does not make it a programming language. Programming languages have "variables" in it to pass and manipulate data. CSS doesn't have that.
But it does have something similar:
"Custom properties" are very limited CSS variables. They can change value and thus change the styles of elements. You can either set them on the :root of the document or on the element in question. They then cascade down into children elements, like this:
The syntax is a little odd, but the variable is defined with a --name, followed by a value. To reference it you place it inside a var() attribute. You can also provide alternatives values if the value hasn't been set. To do this, add the alternative value after the variable inside the var() attribute like so:
You can also store multiple properties inside a CSS variable, like so:
Okay, so you can use variables and do math. That isn't exactly "programming". Programming also includes "if statements". Does CSS have those now too?
Does your browser support some modern styles like flexbox? Or did you want to add custom styles like Webkit's stroke? CSS's @supports can now style elements according to your browser's support:
However, if a browser doesn't support @supports, it also doesn't support @supports not. This means @supports is not a good way to style around older browsers like Internet Explorer. (But there are other ways to do that.)
Okay, so now we have math, variables and somewhat of an "if statement". What about loops? CSS does not have that.
To call CSS a programming language would be incorrect, but it would also be incorrect to say it isn't. CSS has made leaps and bounds over the past few years and is moving in the way of programming languages. With the recent addition of CSS variables / custom properties, a lot more possibilities have opened up.