What is the specificity of the attribute selector?

前端 未结 3 1335
暗喜
暗喜 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:47

    In general, all types of selectors are the same; what matters is the number of selectors in the expression. So ID = 1, class = 1, and HTML tag = 1.

    In the event that two selectors have the same specificity, the one that is further down in the CSS file "wins". So make sure you order your CSS references from the general to the specific; libraries like jquery-ui.css go first, while your CSS files go after those.

提交回复
热议问题