0
0
Tailwindmarkup~20 mins

Defining grid columns in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Grid Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the effect of this Tailwind CSS class?
Consider the following HTML snippet using Tailwind CSS:
<div class="grid grid-cols-3 gap-4">...</div>

What does the class grid-cols-3 do?
Tailwind
<div class="grid grid-cols-3 gap-4">Content</div>
ACreates a flex container with 3 items.
BCreates a grid container with 3 rows.
CCreates a grid container with 3 equal-width columns.
DCreates a grid container with 3 columns of fixed 3rem width.
Attempts:
2 left
💡 Hint
The class grid-cols-3 controls the number of columns in a grid layout.
🧠 Conceptual
intermediate
2:00remaining
How does Tailwind CSS define grid columns with different widths?
Which Tailwind CSS class would you use to create a grid with 4 columns where the first column is twice as wide as the others?
Agrid-cols-[2fr_1fr_1fr_1fr]
Bgrid-cols-4 grid-cols-2
Cgrid-cols-4 grid-cols-auto
Dgrid-cols-4 grid-cols-fr
Attempts:
2 left
💡 Hint
Tailwind allows custom grid column sizes using square brackets with CSS values.
selector
advanced
2:00remaining
Which Tailwind class correctly creates a responsive grid with 2 columns on small screens and 4 columns on large screens?
Given the following options, which one will create a grid that has 2 columns on screens smaller than 1024px and 4 columns on screens 1024px and wider?
Agrid grid-cols-2 md:grid-cols-4
Bgrid grid-cols-4 sm:grid-cols-2
Cgrid grid-cols-4 lg:grid-cols-2
Dgrid grid-cols-2 lg:grid-cols-4
Attempts:
2 left
💡 Hint
Tailwind uses prefixes like lg: to apply styles at certain screen sizes.
rendering
advanced
2:00remaining
What will be the visual layout of this grid container?
Analyze this HTML snippet:
<div class="grid grid-cols-3 gap-2">
  <div>A</div>
  <div>B</div>
  <div>C</div>
  <div>D</div>
</div>

How will the items be arranged visually?
Tailwind
<div class="grid grid-cols-3 gap-2">
  <div>A</div>
  <div>B</div>
  <div>C</div>
  <div>D</div>
</div>
AAll items in one row: A B C D
BFirst row: A B C; second row: D alone in first column
CFirst row: A B; second row: C D
DFirst row: A B C D; second row empty
Attempts:
2 left
💡 Hint
The grid has 3 columns, so items fill rows left to right.
accessibility
expert
3:00remaining
Which approach improves accessibility for a grid layout of images with captions?
You have a grid of images with captions inside a div using Tailwind grid classes. Which method best improves accessibility for screen readers?
AUse semantic <code>&lt;figure&gt;</code> and <code>&lt;figcaption&gt;</code> elements for each image and caption.
BAdd <code>aria-label</code> to the grid container describing the images.
CUse <code>alt=""</code> on images and put captions in <code>&lt;span&gt;</code> elements.
DWrap images in <code>&lt;div&gt;</code> with <code>role="gridcell"</code> but no captions.
Attempts:
2 left
💡 Hint
Semantic HTML elements help screen readers understand content better.