CSS Selector Specificity
Which color is the element?
<ul id="names">
<li>Gal</li>
<li>Asaf</li>
<li>Roy</li>
</ul>
ul#names li {
color: red;
}
Which color is the element?
<ul id="names">
<li>Gal</li>
<li>Asaf</li>
<li class=”ios”>
Roy
</li>
</ul>
.ios {
color: green;
}
ul#names li {
color: red;
}
Which color is the element?
.ios {
color: green;
}
To the CALC machine!
ul#nav li.last 0 1 1 2
body.fbs_2 a[href] span 0 0 2 3
<li style=”color: red”> 1 0 0 0
ul li ul li ol a:first-letter 0 0 0 7
li.last { color: red !important;} 1 0 0 0 0
ul#names li {
color: red;
}
Trump card
.ios {
color: green !important;
}
li.last {
border-top: none !important;
}
a {
text-decoration: none !important;
}
When it makes sense
What if scores are equal?
How many class names outscore an id?
.c1.c2.c3.c4.c5.c6.c7.c
8.c9.c11.c12 0 0 12 0
#id1 0 1 0 0
CSS Selector Specificity

CSS Selector Specificity