Because CSS is not a programming language, instead, it is the configuration file that contains the variable data for your program.
Currently CSS is so powerful that you can actually program in it, but that is besides the point. In essence it's still a stylesheet language.
Let's take a step back. Imagine we have a programming language that can draw on a screen. Imagine we want to program it to paint a web page.
At first we would enter tons of magic numbers in our code. The margin width, the text height, indentations, etc., etc.
jump(100) // The margin
drawTable(500, 500)
writeText("Hello World", 12)
So we extract the magic numbers, and put them on top of our file.
int margin = 100
int table = 500
int text_size = 12
jump(margin) // The margin
drawTable(table, table)
writeText("Hello World", text_size)
Now this is a bit ugly. We rather read our variable numbers from a configuration file.
margin 100
table 500
text size 12
Mm, that's a bit unclear... What do those numbers mean? What do those names mean? Let's formalize it a bit.
margin_left 10em
table_width 500px
table_height 500px
font_size 12px
But you know, we want to expand our program a little bit. We also want it to draw pages with multiple tables, pages without tables, pages with paragraphs or buttons and what more. Let's add selectors to our configuration file so we can specify what paragraph should have a larger font, or different text colour, perhaps we can support nested elements, perhaps we can use a general property in our configuration file, and then override it with a specific one in a few nested elements.
You feel where this is going, eventually you arrive as CSS. (And a browser to render it.)
Should we then add capabilities to our configuration file so we can avoid magic numbers again? Add variables? Add a configuration file for our CSS file? It feels a bit pointless if you remember our CSS file is that very same configuration file already.
But that is not true of course; your CSS file grows larger and larger, and eventually you run into the same problems as with the original magic numbers, the same number repeated all over the place, sometimes with a small transformations, etc.
Modern CSS however, allows many ways to avoid this repetition. You can use classes that apply to many elements, you can set style for all div
s, but then override one specifically, and CSS 3 even allows some kind of variable usage.
That does not mean you need to start using CSS variable in every possible location. Use it where it makes sense and use it where you avoid duplication or where other techniques also available fall short.
In the end, you do not want too many magic numbers in your configuration file either :-)