
Shobha
The best way to predict the future is to invent it
What is specificity, and how is it calculated in CSS?
Specificity in CSS refers to how the browser decides which style rule to apply when multiple rules target the same element. It’s based on a scoring system that assigns different values to selectors like inline styles, IDs, classes, and elements. The more specific the selector, the higher its score.
Calculation example:
Inline styles: 1000
ID selectors: 100
Class selectors, pseudo-classes: 10
Element selectors: 1
Calculation example:
Inline styles: 1000
ID selectors: 100
Class selectors, pseudo-classes: 10
Element selectors: 1