What is Specificity?
If there are two or more CSS rules that point to the same element, the selector with the highest specificity will “win”, and its style declaration will be applied to that HTML element.
Think of specificity as a hierarchy that determines which style declaration is ultimately applied to an element.
Look at the following examples:
Example 1
Here, we have used the “p” element as selector, and specified a red color for this element. Result: The text will be red:
<html>
<head>
<style>
p {color: red;}
</style>
</head>
<body>
<p>Hello World!</p>
</body>
</html>