html - What is the specificity of the attribute selector? -


I'm wondering what is the attribute selection's attribute for example:

  • ID = 100 points
  • class = 10 marks
  • HTML tags = 1 point

    Example:

      / * This specificity value is 100 + 10 + 1 = 111 * / #hello. Class h2 {}   

    with this HTML:

      & lt; Div class = "selectform" & gt; & Lt; Input type = "text" value = "inter text" & gt; & Lt; Input type = "text" value = "difference text" class = "input" & gt; & Lt; / Div & gt;   

    Which of these 2 selectors is more specific?

     . Select input [type = "text"] {} .selectform .inputbg {}   

    check on demo

    Attribute Chooser

    In your example, the first selector is more specific because one additional type selector is input By which he defeats the second selector.

    The specificity of each selector is as follows:

      / * 1 category, 1 attribute, 1 type - & gt; Specification = 0-2-1 * /. Selection input [type = "text"] {} / * 2 squares - & gt; Specification = 0-2-0 * / .selectform .inputbg {}    

Comments