Understanding CSS selectors

前端 未结 5 945
一个人的身影
一个人的身影 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:05

    According to http://htmldog.com/guides/cssadvanced/specificity/, '#' (An id selector) has the highest specificity, so yes, anything with a '#' will precede anything which doesn't, if they refer to the same thing.

    Check that link for more info.

提交回复
热议问题