Does embedded css always override external css?

前端 未结 4 1850
南方客
南方客 2020-12-11 02:05

I had studied earlier that embedded CSS always overrides external css. But I found that whichever comes last in the code, those styles prevail.

Please see the follo

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-11 02:20

    After all the rules of css, if there are 2 with the same specificity, the last one defined will take over.

    For example, writing:

    div { 
        background: green;
    }
    
    
    div {
        background: red;
    }
    

    Will turn it red regardless of the source.

提交回复
热议问题