0
0
CSSmarkup~20 mins

Align items in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flexbox Alignment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does align-items: center; do in a flex container?
Consider a flex container with multiple items inside. What is the effect of setting align-items: center; on the container?
CSS
display: flex;
align-items: center;
AIt centers the flex items horizontally along the main axis.
BIt spaces the flex items evenly with equal gaps between them.
CIt centers the flex items vertically along the container's cross axis.
DIt aligns the flex items to the start of the main axis.
Attempts:
2 left
💡 Hint
Think about the difference between main axis and cross axis in flexbox.
📝 Syntax
intermediate
2:00remaining
Which CSS snippet correctly aligns flex items to the bottom of the container?
You want all flex items inside a container to align at the bottom edge vertically. Which CSS code achieves this?
CSS
display: flex;
/* align-items property here */
Aalign-items: flex-end;
Balign-items: flex-start;
Calign-items: center;
Dalign-items: stretch;
Attempts:
2 left
💡 Hint
Remember that flex-end aligns items at the end of the cross axis.
selector
advanced
2:00remaining
Which CSS selector targets only flex containers with align-items: center;?
You want to style only flex containers that have align-items: center; set. Which selector correctly matches these containers?
Adiv[style*='align-items: center']
Bdiv.align-items-center
Cdiv:has(> *:align-items(center))
Ddiv[align-items='center']
Attempts:
2 left
💡 Hint
Think about attribute selectors and inline styles.
layout
advanced
2:00remaining
What visual effect does align-items: stretch; have on flex items?
Given a flex container with fixed height, what happens to the height of flex items when align-items: stretch; is applied?
CSS
display: flex;
align-items: stretch;
height: 200px;
AFlex items center vertically without changing height.
BFlex items keep their original height and align at the top.
CFlex items shrink to the smallest height among them.
DFlex items expand to fill the container's height.
Attempts:
2 left
💡 Hint
Stretch means to fill the available space along the cross axis.
accessibility
expert
3:00remaining
How does improper use of align-items affect keyboard navigation in flex layouts?
If flex items are visually aligned with align-items but their DOM order differs, what accessibility issue can arise?
AFlex items become unreachable by keyboard navigation.
BKeyboard users may experience confusing focus order not matching visual layout.
CScreen readers will ignore the flex container entirely.
DThe browser automatically fixes focus order to match visual alignment.
Attempts:
2 left
💡 Hint
Visual order and DOM order can differ in flexbox.