That is exactly the same as the first code I posted, which I noted was valid, though? I am asking why it is valid there, but not within body. Closing that bracket ends my declaration for body, meaning that declaring it outside while remaining within the head is, indeed, making it global. Correct?
If so, placing them within body, on the other hand, would "practically" be assigning it as a global, without literally doing so, is what I am thinking.
Simply put, it seems like quite the opposite of what you said, and I cannot assign local variables for different elements.
and I do hope I'm not coming off as a cunt, I'm just failing to make connections. It doesn't seem to make sense to me.
Edit: Although it did not answer my question, your first example code gave me an idea. Thanks.![]()
1. CSS doesn't nest in the way that programming languages do. Having a CSS <body> tag begin with a bracket doesn't imply the opening brace { is the same as the brace in a function declaration. In CSS, body and a:link are individual objects. Nesting one inside the other doesn't work from a hierarchy perspective. It should be:
body { css goes here; }
a:link { css goes here; }
Nesting one inside the other is a no-go.
For things like divs, its like this:
.random_div { css goes here; }
.random_div a:link { css goes here; }
The a:link and the a:link declared as a subset of .random_div both have a different scope.
If there's text encapsulated within a div: <div class="random_div"> -text, text, text- </div> its local and separate from the main a:link.
2. Declaring things within <head></head> does nothing to make things global. The reason for putting code in <head> has to do with order of operations. The <head> area is the first thing that is loaded in a html document when the page loads. Placing your style or code there ensures its loaded before everything else.
3. No worries, no one starts out knowing everything.

.