33 lines
732 B
Plaintext
33 lines
732 B
Plaintext
== Why is this an issue?
|
|
|
|
Order of instructions in CSS is important: instructions with equal specificity that occur later in the file take the priority. But when a selector with a higher specificity (e.g. ``++p a { color: green;}++``) comes before the selector it overrides (e.g.: ``++a { color: green;}++``), the priority is given to the first one. Even if it works properly, this is harder to anticipate the behaviour of the stylesheet while reading as it goes against the principle that the last instruction takes the priority.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,css]
|
|
----
|
|
p a {
|
|
color: green;
|
|
}
|
|
|
|
a {
|
|
color: blue;
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,css]
|
|
----
|
|
a {
|
|
color: blue;
|
|
}
|
|
|
|
p a {
|
|
color: green;
|
|
}
|
|
----
|
|
|