Do We Actually Need Specificity In CSS?

Avatar of Chris Coyier
Chris Coyier on

DigitalOcean provides cloud products for every stage of your journey. Get started with $200 in free credit!

Philip Walton:

While it’s not possible to simply instruct the browser to ignore specificity altogether, it is possible to prevent specificity from affecting the cascade for a particular CSS file or set of CSS files.

How? The answer is to make specificity and source order the same.

Imagine a stylesheet in which all rules were ordered from least specific to most specific. In such a stylesheet, since the specificity of the rules also corresponds to the source order or the rules, specificity is effectively taken out of the equation.

Most arguments about the failures of CSS involve the global-ness and the pains of specificity. Thus most proposed solutions involve attempting to remove the global-ness or flatten specificity.

Direct Link →