From the course: CSS Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Specificity

Specificity

- [Instructor] We talked about the cascade, which determines that the last style rule takes precedence when styles conflict. However, when different types of selectors are used, source order is overridden by a concept called specificity. Specificity refers to the rules which determine which CSS style takes precedence when styles conflict but it's based on the type and number of selectors used. With some having more weight than others, the higher the specificity, the more priorities a selector has when applying styles to an element. Here's how the selectors are weighted from highest to lowest specificity, ID, class, type, then universal. These values are calculated based on the selector type and the number of each type of selector used. Here's how the specificity calculations work. It's broken down into a three category count. The number of ID selectors, the number of class selectors, and the number of type selectors.…

Contents