Reputation: 16055
From what I've read css
styles overwrite each other depending on the order of inclusion. But I'm experiencing some strange behavior, shown in the picture:
It is clearly visible that default.css
is included after base.css
which would suppose that styles from default.css
will overwrite styles from base.css
. However this is not the case, as you see, the style from base.css
persists and the style from default.css
is being cancelled out. Why is that?
Upvotes: 0
Views: 68
Reputation: 6857
Your style from default.css has a more specific selector so will overwrite the base.css style. You may want to google how specificity points work in determining how css gets applied.
Upvotes: 1
Reputation: 112895
This is because CSS class selectors (e.g., .marginblock
in your example) has a higher precedence than CSS type selectors (body
in your example).
If your CSS were as follows, you would have the behavior you expect:
In base.css
:
.marginblock {
margin: 0 auto;
}
In default.css
:
.marginblock {
margin: 25px;
}
Here's more detail on the CSS order of precedence:
More information can be found here.
Upvotes: 2