Loading...
Loading...
Cascade (Cascading) is the main mechanism that determines which style will be applied when multiple CSS rules target the same element.
CSS stands for Cascading Style Sheets — cascading style sheets. The word "cascading" indicates that styles overlay each other and are applied according to certain priority rules.
When multiple CSS rules are applied to one element, the browser chooses the one with highest priority. This considers:
How "precisely" the CSS rule targets the element. Higher specificity means higher priority.
div a /* low specificity */
.menu a /* higher */
#header a /* even higher */
If !important is added to a property, it overrides even more specific rules.
p { color: red !important; }
Source of the style:
style="...")<link> / @import)If specificity is equal, the style that comes last in code wins.
Recommendation:
Avoid excessive use of !important — it complicates code support and debugging.