CSS Cascade and Specificity Resolution Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 6575 | Total Attempts: 67,424
| Questions: 15 | Updated: May 2, 2026
Please wait...
Question 1 / 16
🏆 Rank #--
0 %
0/100
Score 0/100

1. Which selector has the highest specificity weight in CSS?

Explanation

In CSS, specificity determines which styles are applied when multiple rules match an element. The ID selector carries the highest specificity weight because it is designed to uniquely identify a single element, thus overriding styles from element and class selectors, which have lower specificity. This makes ID selectors the most powerful in controlling styling.

Submit
Please wait...
About This Quiz
CSS Cascade and Specificity Resolution Quiz - Quiz

This CSS Cascade and Specificity Resolution Quiz tests your understanding of how CSS rules are applied and prioritized in web design. You'll explore cascade principles, specificity calculations, and inheritance rules that determine which styles win when multiple rules target the same element. Essential for writing maintainable CSS and debugging style... see moreconflicts. see less

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. What is the specificity value of the selector #header .nav a?

Explanation

The specificity of the selector #header .nav a is calculated by counting the components: 1 ID selector (#header), 1 class selector (.nav), and 1 type selector (a). This results in a specificity value of (1, 1, 0, 1), reflecting the contribution of each type of selector to the overall specificity.

Submit

3. Which property overrides normal cascade rules in CSS?

Explanation

The `!important` declaration in CSS is used to give a style rule higher priority than normal cascading rules. When applied to a property, it ensures that this rule takes precedence over other conflicting styles, regardless of their specificity or order in the stylesheet, making it a powerful tool for overriding styles.

Submit

4. In the cascade, which stylesheet has the lowest priority?

Explanation

User agent stylesheets are default styles provided by web browsers. They have the lowest priority in the CSS cascade because they can be easily overridden by external stylesheets, internal styles, and inline styles, which are more specific and take precedence in styling web content.

Submit

5. Two selectors have equal specificity. Which rule applies?

Explanation

When two CSS selectors have equal specificity, the browser applies the rule that appears last in the stylesheet. This is based on the "Cascading" nature of CSS, where later rules override earlier ones if they have the same specificity, ensuring that the most recent declaration takes precedence.

Submit

6. What is the specificity of the selector div.container#main?

Explanation

The specificity of the selector div.container#main is calculated based on its components: 1 ID selector (#main), 1 class selector (.container), and 1 type selector (div). This results in a specificity score of (1, 1, 1, 0), indicating one ID, one class, and one type selector, with no inline styles.

Submit

7. Which CSS rule will override p { color: blue; } if both are in the same stylesheet?

Explanation

The rule `#paragraph { color: red; }` overrides `p { color: blue; }` because it uses an ID selector, which has a higher specificity than the type selector for paragraphs. In CSS, specificity determines which styles are applied when multiple rules match the same element, with ID selectors being more specific than type selectors.

Submit

8. In CSS inheritance, which property is NOT inherited by default?

Explanation

In CSS, properties like font-size, color, and line-height are inherited by child elements from their parent elements, allowing for consistent styling. However, the margin property is not inherited by default; instead, it applies individually to each element. This design helps maintain layout control without unintended spacing effects from parent elements.

Submit

9. A rule in an external stylesheet conflicts with an inline style. Which wins?

Explanation

Inline styles have higher specificity compared to external stylesheets, meaning they take precedence when both are applied to the same element. This prioritization ensures that any styles defined directly within an element's HTML will override those specified in external stylesheets, providing more control over the element's appearance.

Submit

10. What does the universal selector (*) contribute to specificity?

Explanation

The universal selector (*) has no specificity value, meaning it does not contribute to the specificity hierarchy in CSS. It matches all elements but does not override other selectors with higher specificity. Therefore, its specificity is represented as (0, 0, 0, 0), indicating it has the lowest precedence.

Submit

11. Which statement about CSS cascade is true?

Explanation

In CSS, author styles are defined by the web developer and take precedence over user agent styles, which are the default styles applied by the browser. This ensures that the developer's design choices are prioritized, allowing for greater control over the appearance of web pages.

Submit

12. The cascade priority from lowest to highest is: author, user agent, ____.

Explanation

In the context of CSS and styling, the cascade priority determines how styles are applied. It ranks the sources of styles based on their specificity. The hierarchy from lowest to highest starts with author styles, followed by user agent styles (browser defaults), and finally user styles, which allow individual users to override other styles for customization.

Submit

13. A pseudo-class like :hover contributes ____ to specificity calculation.

Submit

14. When two rules have identical specificity, the ____ rule in the source wins.

Submit

15. The CSS property that forces a rule to override all others is ____.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (15)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which selector has the highest specificity weight in CSS?
What is the specificity value of the selector #header .nav a?
Which property overrides normal cascade rules in CSS?
In the cascade, which stylesheet has the lowest priority?
Two selectors have equal specificity. Which rule applies?
What is the specificity of the selector div.container#main?
Which CSS rule will override p { color: blue; } if both are in the...
In CSS inheritance, which property is NOT inherited by default?
A rule in an external stylesheet conflicts with an inline style. Which...
What does the universal selector (*) contribute to specificity?
Which statement about CSS cascade is true?
The cascade priority from lowest to highest is: author, user agent,...
A pseudo-class like :hover contributes ____ to specificity...
When two rules have identical specificity, the ____ rule in the source...
The CSS property that forces a rule to override all others is ____.
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!