What is the specificity of the attribute selector?

前端 未结 3 1325
暗喜
暗喜 2020-12-09 15:47

I\'m wondering what the specificity of the attribute selector is. For example:

  • Id = 100 points
  • Class = 10 points
  • Html Tag= 1 point
3条回答
  •  时光取名叫无心
    2020-12-09 16:32

    As someone said earlier in this post "attribute selectors have the same specificity as classes"...i find that not to be true from my experiences... i have used a class name after say an input[type="text"] and it would not override the previous CSS. It's counter-intuitive since input[type="text"] sounds quite broad . You have to use an ID to override which if you are doing inputs for forms you should have an ID on there anyways to properly connect labels.

提交回复
热议问题