Challenge - 5 Problems
Masonry Grid Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ layout
intermediateWhat is the output of this Bootstrap masonry grid code?
Given the following Bootstrap 5 code snippet, what will the visual layout look like in a modern browser?
Bootsrap
<div class="row row-cols-3 g-3" style="display: block; column-count: 3;"> <div class="col">Item 1</div> <div class="col">Item 2</div> <div class="col">Item 3</div> <div class="col">Item 4</div> <div class="col">Item 5</div> <div class="col">Item 6</div> </div>
Attempts:
2 left
💡 Hint
Think about how CSS column-count affects layout and how Bootstrap's row-cols class works together.
✗ Incorrect
The CSS property column-count: 3 creates three columns where content flows vertically, stacking items unevenly to create a masonry effect. Bootstrap's row-cols-3 sets the grid to three columns but does not override the column-count behavior. So items stack vertically in each column, producing uneven column heights typical of masonry layouts.
❓ selector
intermediateWhich CSS selector correctly targets all masonry grid items inside a Bootstrap column?
You want to style all items inside a Bootstrap masonry grid that uses
row-cols-4 and col classes. Which selector will select all grid items correctly?Attempts:
2 left
💡 Hint
Remember that Bootstrap places the
col elements directly inside the row container.✗ Incorrect
In Bootstrap, the
row-cols-4 class is applied to the row container, and the direct children with class col are the grid items. The selector .row-cols-4 > .col selects all direct children with class col inside the row with row-cols-4.🧠 Conceptual
advancedWhy does using
column-count with Bootstrap's grid create a masonry effect?Explain why combining CSS
column-count with Bootstrap's grid classes results in a masonry-style layout rather than a uniform grid.Attempts:
2 left
💡 Hint
Think about how content flows inside columns versus rows.
✗ Incorrect
CSS
column-count splits content vertically into columns, so items flow top to bottom in each column, stacking unevenly if their heights differ. Bootstrap's grid arranges items horizontally in rows. Combining them causes the vertical stacking from column-count to create the masonry effect.📝 Syntax
advancedWhat error occurs with this Bootstrap masonry grid CSS?
Consider this CSS snippet used with a Bootstrap grid:
.row {
column-count: 3
column-gap: 1rem;
}
What error will this cause?
Bootsrap
.row {
column-count: 3
column-gap: 1rem;
}Attempts:
2 left
💡 Hint
Check CSS syntax carefully for missing punctuation.
✗ Incorrect
CSS requires semicolons to separate declarations. Missing the semicolon after 'column-count: 3' causes a syntax error, so the browser ignores that rule and may ignore the next one too.
❓ accessibility
expertHow to improve accessibility for a Bootstrap masonry grid with many items?
You have a Bootstrap masonry grid with many cards containing images and text. What is the best way to improve accessibility for screen reader users?
Attempts:
2 left
💡 Hint
Think about how screen readers understand content and navigation.
✗ Incorrect
Adding descriptive
aria-label attributes helps screen readers understand each card's purpose. Meaningful alt text on images ensures users who cannot see images get the content description. Avoid removing text or disabling keyboard focus as that harms accessibility.