The priority of using styles is driven by more complicated algorithms than just an order on inclusion in HTML. The CSS style is chosen with the most specific selection rule, where inline rules are considered more specific then externally attached, then selection by ID, then the class and at the end selection with tag name. For example, the paragraph <p id="xyz" class="xyz">
will be red independently of the order of rules:
.xyz {
color: blue;
}
#xyz {
color: red;
}
If there are two rules with the same selection type, the number matters. So, selection .xyz .abc
is "stronger" then .qwerty
.
If two rules have equivalent selection in terms of numbers in each category, then, in the very end order is taken into account...
You can also force a different order with the !important
directive.
Read more about it with "CSS specificity" keywords.