<html>
<style type = "text/css">
.red {
color: red ;
}
.blue {
color: blue;
}
</style>
<body>
<p class="red">this is red</p>
<p class="blue">this is blue</p>
<p class="red blue"> this is what </p>
<p class="blue red"> this is what </p>
<p class="red red"> this is what </p>
</body>
</html>
Copy the code
There is no doubt about the color of the first two P tags. For the third and fourth p’s, if two different class selectors maintain different colors, the selector that appears later in the CSS file has higher precedence, regardless of the order in which the class appears in the P tag.
If the first red selector in the CSS is added! Important attribute, red selector appears first, but its priority is also higher than that of blue selector:For more of Jerry’s original articles, please follow the public account “Wang Zixi “: