0
0
CSSmarkup~5 mins

Debugging specificity issues in CSS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is CSS specificity?
CSS specificity is a set of rules browsers use to decide which CSS rule applies when multiple rules target the same element. It works like a score system based on selectors used.
Click to reveal answer
beginner
How do inline styles affect CSS specificity?
Inline styles have the highest specificity and override most other CSS rules except for !important declarations.
Click to reveal answer
intermediate
What is the specificity order from lowest to highest?
Element selectors (e.g., div) < Class selectors (e.g., .class) < ID selectors (e.g., #id) < Inline styles.
Click to reveal answer
intermediate
How can you debug specificity issues in the browser?
Use browser DevTools to inspect the element, check the Styles pane to see which rules apply and which are overridden, and look at the specificity scores or crossed-out styles.
Click to reveal answer
beginner
What does the !important declaration do in CSS?
The !important declaration forces a CSS rule to override other rules regardless of specificity, but it should be used sparingly to avoid confusion.
Click to reveal answer
Which selector has the highest specificity?
AID selector (#id)
BClass selector (.class)
CElement selector (div)
DUniversal selector (*)
What happens if two CSS rules have the same specificity?
ABoth rules apply simultaneously
BThe rule that appears first in the CSS file applies
CThe rule that appears last in the CSS file applies
DThe browser randomly picks one
How can you check which CSS rule is applied to an element?
AUse a text editor
BGuess based on the CSS file order
CCheck the HTML source code only
DUse browser DevTools and inspect the element
Which of these increases specificity the most?
AAdding more element selectors
BAdding an ID selector
CAdding more class selectors
DAdding a pseudo-class
What is the effect of !important in CSS?
AIt makes a rule override others regardless of specificity
BIt lowers the specificity of a rule
CIt disables the rule
DIt only works on inline styles
Explain how CSS specificity works and why it matters when styling a webpage.
Think about how multiple rules can target the same element.
You got /3 concepts.
    Describe steps you would take to debug a CSS specificity issue using browser tools.
    Use the Styles pane in DevTools to see which rules win.
    You got /4 concepts.