rspec/rules/S4664/css/rule.adoc

31 lines
704 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
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.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,css]
2021-04-28 16:49:39 +02:00
----
p a {
color: green;
}
a {
color: blue;
}
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,css]
2021-04-28 16:49:39 +02:00
----
a {
color: blue;
}
p a {
color: green;
}
----