Understanding CSS selectors

前端 未结 5 946
一个人的身影
一个人的身影 2020-12-16 07:58

Why is it that the below makes the text red?

#stories li a {color:red}
.default li.expand a {color:green}
li.expand a {color:blue}

         


        
5条回答
  •  星月不相逢
    2020-12-16 08:12

    It's a matter of "CSS Specificity". Andy Clarke's article CSS: Spcificity Wars does a pretty good job explaining it with a little humor. Although Eric Meyer adds more clarity in his comment.

提交回复
热议问题