The first rule is more specific than the second, therefore, in the case when both selectors are valid, a more specific one redefines the others.
Read this article to find out how we can overcome the challenges of conflicting styles. To talk about them, here's how the specifics are calculated.
+--------------------+--------------------+-----------------------------------+ | Type | Specific Value | Example | +--------------------+--------------------+-----------------------------------+ | Inline Style | 1000 | style="color: #f00;" | +--------------------+--------------------+-----------------------------------+ | Id | 100 | #text { color: #f00; } | +--------------------+--------------------+-----------------------------------+ | Classes | 10 | .text { color: #f00; } | +--------------------+--------------------+-----------------------------------+ | Pseudo Classes | 10 | a:hover { color: #f00; } | +--------------------+--------------------+-----------------------------------+ | Pseudo Elements | 10 | a:first-child { color: #f00; } | +--------------------+--------------------+-----------------------------------+ | Elements (tag) | 1 | a { color: #f00; } | +--------------------+--------------------+-----------------------------------+
In principle, class selectors are more specific than tag selectors. Allows you to calculate your specificity
- For the first rule: 31
- For the second rule: 30
SO first rule wins.
You can increase the specification of the second rule, for example
.some tr td.other:before { content:url('path/to/image2.png') ; }
Compute it to 33 to override the first rule of the style.
Starx
source share