I’m assuming you’re talking about the CSS stuff, right? If so, then I should clarify that they aren’t variables, they’re selectors. “Selectors” are what you use in CSS to “select” what HTML elements on the page that the styling in the next { ... }
block affects.
The “.
” in front of selectors is just shorthand for “class”. You’ll also see “#
” in front of some selectors, and that’s shorthand for “ID”. Selectors without either of those characters in front usually refer to HTML element types.
Let’s give a quick example. Say you have this HTML on a page:
<a class="classname" id="idname" href="https://www.google.com/">Google</a>
In CSS you can target all <a>
links, including that one, like this:
a {
color: red;
}
That would make all links red.
But if you only want to target elements with that “classname” class, you could do this instead:
.classname {
color: green;
}
That would make the text in all elements with the “classname” class green.
Or, if you want to target that specific element, you could use its “idname” ID like this:
#idname {
color: blue;
}
That would make text in the element with the ID of “idname” blue.
Note that IDs should be unique on the page, so if you’re giving more than one element the same ID then that’s not valid HTML. On the other hand, the same class can be used on multiple elements at the same time.
Now, let’s say that you added all of those bits of CSS to your game at once. Which one would affect the line of HTML I gave above? Well, CSS prefers the more specific selectors over the more general selectors. So the “a
” selector would be the most general, the “.classname
” selector would be next, and then “#idname
” would be the most specific selector, so that last one would be the one that’s applied to that line of HTML. Other links would still be colored red, since the “a
” styling would still be applied to them, unless some other, more specific, styling overrode that. (See the “SpeciFISHity” chart, which shows a list of least-to-most specific CSS selectors using cute “fish”.)
What if there’s a tie for specificity? Then the last one listed will win. That’s part of what the “cascading” in “Cascading Style Sheets” (CSS) means.
There are a lot more selector tricks you can use, so I’d recommend bookmarking and using this page on “CSS Selectors” if you’re having trouble targeting specific elements in your HTML with CSS styling.
Hope that helps!