What is the specificity of the selector 'ul.nav > li.active a:hover'?

Prepare for the CSS Mastery Recipient Portal Test. Study with comprehensive questions and in-depth explanations. Enhance your CSS skills and ace your test!

Multiple Choice

What is the specificity of the selector 'ul.nav > li.active a:hover'?

Explanation:
The idea being tested is how CSS counts specificity across the different kinds of selectors you use. Specificity is built from four parts, but the child combinator itself doesn’t add to any part. What matters here are three groups: IDs, class-like selectors (that is, classes, attributes, and pseudo-classes), and element selectors. In the selector given, there are no ID selectors. There are two class selectors (.nav and .active) plus one pseudo-class (:hover), which together count as three in the class-like group. There are three element selectors: ul, li, and a. So the breakdown is: zero IDs, three class-like selectors, and three element selectors. This is why the correct interpretation matches a distribution with zero in the ID part, three in the class-like part, and three in the element part.

The idea being tested is how CSS counts specificity across the different kinds of selectors you use. Specificity is built from four parts, but the child combinator itself doesn’t add to any part. What matters here are three groups: IDs, class-like selectors (that is, classes, attributes, and pseudo-classes), and element selectors.

In the selector given, there are no ID selectors. There are two class selectors (.nav and .active) plus one pseudo-class (:hover), which together count as three in the class-like group. There are three element selectors: ul, li, and a.

So the breakdown is: zero IDs, three class-like selectors, and three element selectors. This is why the correct interpretation matches a distribution with zero in the ID part, three in the class-like part, and three in the element part.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy