0
0
CSSmarkup~20 mins

Writing reusable CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSS Reusability Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2:00remaining
Which CSS selector targets all buttons inside a section with class card?
You want to style all <button> elements that are inside any <section> with class card. Which selector correctly does this?
Abutton.card section { color: blue; }
B.card > button { color: blue; }
Csection.card button { color: blue; }
Dsection button.card { color: blue; }
Attempts:
2 left
💡 Hint
Think about how to select buttons that are inside a section with a specific class.
layout
intermediate
2:00remaining
What is the effect of this CSS on a container with multiple items?
Consider this CSS code:
.container { display: flex; flex-wrap: wrap; gap: 1rem; }

What will you see when multiple child items are inside .container?
AItems will be arranged in a row and wrap to the next line if needed, with 1rem space between them.
BItems will stack vertically with 1rem space between them.
CItems will overlap each other with no spacing.
DItems will be arranged in a column and never wrap.
Attempts:
2 left
💡 Hint
Remember what flex-wrap: wrap and gap do in flexbox.
accessibility
advanced
2:00remaining
Which CSS practice improves accessibility for keyboard users?
You want to make sure focus outlines are visible for keyboard users but not distracting for mouse users. Which CSS snippet achieves this best?
A:active { outline: none; }
B:focus { outline: none; }
C*:hover { outline: 2px solid #005fcc; }
D:focus-visible { outline: 2px solid #005fcc; }
Attempts:
2 left
💡 Hint
Focus outlines should appear only when using keyboard navigation.
📝 Syntax
advanced
2:00remaining
What error does this CSS code cause?
Look at this CSS snippet:
.btn { background-color: blue; color: white; border-radius 5px; }

What happens when a browser tries to read this?
CSS
.btn { background-color: blue; color: white; border-radius 5px; }
AThe browser applies all styles except border-radius.
BThe browser ignores the entire rule because of missing colon in border-radius.
CThe browser throws a syntax error and stops rendering the page.
DThe browser applies border-radius but ignores color.
Attempts:
2 left
💡 Hint
Check the syntax for property declarations.
🧠 Conceptual
expert
2:00remaining
How many unique CSS classes are used in this HTML snippet?
Given this HTML:
<div class="card primary">
  <button class="btn primary">Click</button>
  <button class="btn secondary">Cancel</button>
</div>

How many unique CSS class names are present in total?
CSS
<div class="card primary">
  <button class="btn primary">Click</button>
  <button class="btn secondary">Cancel</button>
</div>
A2
B4
C5
D3
Attempts:
2 left
💡 Hint
Count each distinct class name only once.