0
0
CSSmarkup~20 mins

Common UI use cases in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSS UI Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
layout
intermediate
2:00remaining
Which CSS rule creates a responsive two-column layout using Flexbox?
You want to create a container that displays two columns side by side on wide screens and stacks them vertically on narrow screens. Which CSS rule achieves this behavior?
CSS
/* Container CSS */
.container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Column CSS */
.column {
  flex: 1 1 300px;
  background-color: lightgray;
  padding: 1rem;
}
ASet .container { display: flex; flex-direction: column; } and .column { flex: 1; }
BSet .container { display: grid; grid-template-columns: repeat(2, 1fr); } and .column { width: 50%; }
CSet .container { display: block; } and .column { float: left; width: 50%; }
DSet .container { display: flex; flex-wrap: wrap; } and .column { flex: 1 1 300px; }
Attempts:
2 left
💡 Hint
Flexbox with wrapping allows columns to stack on narrow screens.
accessibility
intermediate
2:00remaining
Which HTML and CSS combination improves keyboard accessibility for a custom button?
You create a clickable
styled as a button. Which combination ensures it is accessible via keyboard and screen readers?
CSS
<div class="custom-button" tabindex="0" role="button">Click me</div>
AAdd tabindex="0" and role="button" to the div, and style with :focus outline.
BAdd onclick handler only, no tabindex or role needed.
CUse a <span> with role="button" but no tabindex.
DUse a <div> with tabindex="-1" and role="button".
Attempts:
2 left
💡 Hint
Keyboard users need focus and screen readers need role.
selector
advanced
2:00remaining
What does the CSS selector :is(.btn, .link) > span target?
Given the selector :is(.btn, .link) > span, which elements will it select?
AAll elements with class .btn or .link that are direct children of a <span>.
BAll elements with class .btn or .link that contain a <span> child.
CAll <span> elements that are direct children of elements with class .btn or .link.
DAll <span> elements anywhere inside elements with class .btn or .link.
Attempts:
2 left
💡 Hint
The > means direct child, :is groups selectors.
rendering
advanced
2:00remaining
What visual effect does this CSS produce on a button when hovered?
Consider this CSS for a button: .button { background-color: #007BFF; color: white; padding: 1rem 2rem; border-radius: 0.5rem; transition: background-color 0.3s ease; } .button:hover { background-color: #0056b3; } What will the user see when they hover over the button?
AThe button text color changes from white to dark blue instantly.
BThe button background smoothly changes from bright blue to a darker blue over 0.3 seconds.
CThe button border radius increases on hover.
DThe button background color changes instantly with no transition.
Attempts:
2 left
💡 Hint
Look at the transition property and the hover background-color.
🧠 Conceptual
expert
2:00remaining
How many items will be visible in this CSS Grid container with overflow hidden?
Given this HTML and CSS: HTML:
1
2
3
4
5
CSS: .grid-container { display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: 100px; height: 200px; overflow: hidden; } .item { border: 1px solid black; font-size: 2rem; display: flex; justify-content: center; align-items: center; } How many .item elements will be fully visible inside the container?
A4 items
B5 items
C2 items
D3 items
Attempts:
2 left
💡 Hint
Calculate how many grid cells fit in 200px height with 100px rows.