CSS Specificity

Learn about CSS specificity and its rules.

Here, we’ll cover the most common use cases of CSS selectors and understand CSS specificity in detail.

We’ll start with specificity.

Introduction to CSS specificity

CSS specificity is a way for the browser to determine which CSS declarations to apply when it comes across ambiguous syntax.

In other words, it’s a way for the browser to decide which styles to apply when there is more than a single CSS declaration for the same element(s) on the page.

Here’s the HTML, CSS, and the corresponding output:

Get hands-on with 1200+ tech skills courses.