I am trying to understand specificity in CSS.
My current understanding is that specificity is very similar to inheritance, but in some way more specifically defined.
Mozilla Specificity Definition:
Specificity is the means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. Specificity is based on the matching rules which are composed of CSS selectors of different sorts.
The current task is:
Refactor the CSS declarations for .active a
and .copyright
so that the !important
rule can be removed.
CSS:
.main li a {
color: #7ab2c1;
}
.active a {
color: #826c55 !important;
}
.primary p {
font-size: 12px;
}
.copyright {
font-size: 10px !important;
}
And relevant HTML:
<nav class="main">
<ul class="group">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
[...]
<footer class="primary">
<p><a href="#">Sign up</a> for our newsletter, it's a racket!</p>
<p class="copyright">Copyright © Sven's Snowshoe Emporium. All Rights Reserved.</p>
</footer>
Can anyone guide me through the process of refactoring in such a way that helps me to grasp the fundamental concepts?