I’m completing the Basic CSS lessons on variables, and I’m confused. My confusion is in comparing CSS variables to variables in other programming languages.
Question 1. How is variable type being determined? In the examples used for the penguin, we see:
…what exactly is being stored? The text “black”? Or is the browser just intelligently deciding that penguin-skin will be a variable of type “color” or similar? How would I declare that variable without giving it a value? If I later define penguin-skin to be “0” or “rgb(0,0,0)” or “fred jones” will CSS just say “okay, sure, we’ll change the type!”?
Question 2. How does CSS know the domain of a variable… i.e. how local or private it is?
In the examples in the lesson, the variable is declared inside of a class definition early in the block… and then other class definitions, further down, use that variable! This seems bonkers to me… is any variable I define, anywhere, instantly global? Does it go backwards and forwards, or just as you read down the styles? It feels really weird to call CSS classes classes.
Thanks for your thoughts,