0
0
CSSmarkup~20 mins

Debugging specificity issues in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Specificity Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2:00remaining
Which CSS rule will apply the red color to the paragraph?
Given the following HTML and CSS, which CSS selector will make the paragraph text red?
CSS
HTML:
<p class="text">Hello World</p>

CSS:
.text { color: blue; }
#main .text { color: green; }
.text.highlight { color: red; }
A.text { color: red; }
B#main .text { color: red; }
C.text.highlight { color: red; }
Dp.text { color: red; }
Attempts:
2 left
💡 Hint
Think about which selector has the highest specificity and matches the element's classes.
🧠 Conceptual
intermediate
1:30remaining
What is the specificity value of the selector #nav ul li.active a?
Calculate the specificity of the CSS selector #nav ul li.active a. Use the format (a,b,c) where:
- a = number of ID selectors
- b = number of class, attribute, and pseudo-class selectors
- c = number of element and pseudo-element selectors
A(0,2,4)
B(1,1,3)
C(1,2,3)
D(1,1,4)
Attempts:
2 left
💡 Hint
Count each type of selector carefully: IDs, classes, and elements.
rendering
advanced
2:00remaining
Which color will the button have when rendered?
Consider the following CSS and HTML. What color will the button text be when viewed in a browser?
CSS
HTML:
<button class="btn primary">Click me</button>

CSS:
button { color: black; }
.btn { color: blue !important; }
.primary { color: red; }
ABlack
BBlue
CRed
DDefault browser color
Attempts:
2 left
💡 Hint
Remember that !important overrides normal specificity rules.
accessibility
advanced
1:30remaining
Which CSS selector is best to style focus state for accessibility?
You want to improve keyboard navigation by styling the focus state of links. Which selector correctly targets links when they receive keyboard focus?
Aa:focus-visible
Ba:hover
Ca:active
Da:visited
Attempts:
2 left
💡 Hint
Focus styles should appear only when users navigate with keyboard, not mouse.
📝 Syntax
expert
2:00remaining
What error does this CSS snippet cause?
Examine the CSS code below. What kind of error or issue will it cause in the browser?
CSS
div > .item { color: green; }
div > .item { color: blue !important }
div > .item { color: red; }
ASyntax error due to missing semicolon in second rule
BThe first rule overrides the others
CAll rules apply and colors blend
DThe last rule is ignored because of !important in the second rule
Attempts:
2 left
💡 Hint
Check punctuation carefully in CSS declarations.