HTML and CSS Reference
In-Depth Information
Remember that non-CSS presentational markup is attributed with a
specificity of 0, which would apply, for example, to the font tag.
Getting back to the !important declaration, keep in mind that using it on a
shorthand property is the same as declaring all of its sub-properties as !
important (even if that would revert them to the default values).
If you are using imported style sheets ( @import ) in your CSS, you have to
declare them before all other rules. Thus, they would be considered as
coming before all the other rules in the CSS file.
Finally, if two selectors turn out to have the same specificity, the last one will
override the previous one(s).
2.2 MAKING SPECIFICITY WORK FOR YOU
If not carefully considered, specificity can come back to haunt you and lead
you to unwittingly transform your style sheets into a complex hierarchy of
unnecessarily complicated rules.
You can follow a few guidelines to avoid major issues:
• When starting work on the CSS, use generic selectors, and add
specificity as you go along;
• Using advanced selectors doesn't mean using unnecessarily
complicated ones;
• Rely more on specificity than on the order of selectors, so that your style
sheets are easier to edit and maintain (especially by others).
Search WWH ::




Custom Search