I'm wondering what the specificity of the attribute selector is. For example:
- Id = 100 points
- Class = 10 points
- Html Tag= 1 point
Example:
/* this specificity value is 100 + 10 + 1 = 111 */
#hello .class h2 { }
With this HTML:
<div class="selectform">
<input type="text" value="inter text">
<input type="text" value="inter text" class="inputag">
</div>
Which of these 2 selectors is more specific?
.selectform input[type="text"] { }
.selectform .inputbg { }
Check to demo http://tinkerbin.com/IaZW8jbI
.selectform input[type="text"]
has a specificity of2-1
(a class1-0
, a tag1
and an attribute1-0
), while.select-form .inputbg
has a specificty of2-0
(two classes). A2-0
can't override a2-1
. If they were equal (i.e:.selectform input.inputbg
), the last one would have been applied. – Emilie