Jul 18, 2024
**Position and Order of Appearance:
.c-purple
and .c-red
, the latter one applies if both selectors are equal.**Specificity Calculation:
**Origin of CSS:
**Importance (using !important
):
*
): 0 points..yellow
, .c-purple
, and .c-red
each having specificity 10. The one appearing last will apply.h1.yellow
-> h1: 1 point, .yellow
: 10 points → Total: 11 points.a.red
) add up their values.style="color: blue;"
applied directly to the tag will override other CSS rules.#example {color: red;}
will have higher precedence over class selectors .example {color: red;}
.[data-example="true"] {color: green;}
can target elements with specific attributes.!important
:
.example {color: red !important;}
will override inline styles as well.!important
should be used sparingly as they are hard to override.