What is the order of precedence for CSS?

前端 未结 8 1639
攒了一身酷
攒了一身酷 2020-11-22 09:43

I\'m trying to figure out why one of my css classes seems to override the other (and not the other way around)

Here I have two css classes

.smallbo         


        
8条回答
  •  清酒与你
    2020-11-22 10:29

    Element, Pseudo Element: d = 1 – (0,0,0,1)
    Class, Pseudo class, Attribute: c = 1 – (0,0,1,0)
    Id: b = 1 – (0,1,0,0)
    Inline Style: a = 1 – (1,0,0,0)
    

    Inline css ( html style attribute ) overrides css rules in style tag and css file

    A more specific selector takes precedence over a less specific one.

    Rules that appear later in the code override earlier rules if both have the same specificity.

提交回复
热议问题