Bird
Raised Fist0
Tailwindmarkup~10 mins

Why CSS Grid solves complex layouts in Tailwind - Test Your Understanding

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a grid container using Tailwind CSS.

Tailwind
<div class="[1] gap-4">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
</div>
Drag options to blanks, or click blank then click option'
Ainline
Bgrid
Cblock
Dflex
Attempts:
3 left
💡 Hint
Common Mistakes
Using flex instead of grid will create a flexbox layout, not grid.
Using block or inline won't create a grid container.
2fill in blank
medium

Complete the code to define a grid with 3 equal columns using Tailwind CSS.

Tailwind
<div class="grid [1] gap-2">
  <div>Box 1</div>
  <div>Box 2</div>
  <div>Box 3</div>
</div>
Drag options to blanks, or click blank then click option'
Agrid-cols-2
Bgrid-rows-3
Cgrid-flow-col
Dgrid-cols-3
Attempts:
3 left
💡 Hint
Common Mistakes
Using grid-rows-3 sets rows, not columns.
Using grid-cols-2 creates only 2 columns, not 3.
3fill in blank
hard

Fix the error in the code to make the grid items span 2 columns.

Tailwind
<div class="grid grid-cols-4 gap-4">
  <div class="col-span-[1]">Wide Item</div>
  <div>Item 2</div>
  <div>Item 3</div>
</div>
Drag options to blanks, or click blank then click option'
A2
B3
C4
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using col-span-3 spans 3 columns, which may break layout.
Using col-span-1 does not span multiple columns.
4fill in blank
hard

Fill both blanks to create a grid with 2 rows and 3 columns.

Tailwind
<div class="grid [1] [2] gap-3">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>
Drag options to blanks, or click blank then click option'
Agrid-rows-2
Bgrid-cols-4
Cgrid-cols-3
Dgrid-rows-3
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up rows and columns classes.
Using wrong numbers for rows or columns.
5fill in blank
hard

Fill both blanks to create a grid where the first item spans 2 columns and 2 rows.

Tailwind
<div class="grid grid-cols-4 grid-rows-3 gap-2">
  <div class="col-span-[1] row-span-[2]">Big Item</div>
  <div>Item 2</div>
  <div>Item 3</div>
  <div>Item 4</div>
</div>
Drag options to blanks, or click blank then click option'
A1
B2
C3
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 or 4 for spans which may exceed grid size.
Using 1 which means no spanning.

Practice

(1/5)
1. Why is CSS Grid especially good for complex layouts compared to older methods like floats?
easy
A. It only works for single-column layouts.
B. It requires writing lots of extra CSS code.
C. It lets you place items in rows and columns easily without extra markup.
D. It only works on mobile devices.

Solution

  1. Step 1: Understand CSS Grid's layout method

    CSS Grid allows placing items in rows and columns directly, unlike floats which need hacks.
  2. Step 2: Compare with older methods

    Floats require extra wrappers and clearing, making complex layouts hard and messy.
  3. Final Answer:

    It lets you place items in rows and columns easily without extra markup. -> Option C
  4. Quick Check:

    Grid simplifies layout by rows and columns [OK]
Hint: Grid = easy rows and columns, no extra wrappers needed [OK]
Common Mistakes:
  • Thinking Grid only works for simple layouts
  • Confusing Grid with Flexbox for single direction
  • Believing Grid needs lots of extra CSS
2. Which Tailwind class sets a grid with three equal columns?
easy
A. grid-cols-3
B. grid-rows-3
C. grid-gap-3
D. grid-flow-col

Solution

  1. Step 1: Identify the class for columns

    In Tailwind, grid-cols-3 sets the grid to have 3 columns.
  2. Step 2: Check other options

    grid-rows-3 sets rows, grid-gap-3 sets spacing, grid-flow-col changes flow direction.
  3. Final Answer:

    grid-cols-3 -> Option A
  4. Quick Check:

    3 columns = grid-cols-3 [OK]
Hint: Cols = columns, rows = rows in class names [OK]
Common Mistakes:
  • Confusing rows and columns classes
  • Using gap class to set columns
  • Mixing flow direction with column count
3. What will be the visual layout result of this Tailwind code?
<div class="grid grid-cols-2 gap-4">
  <div>A</div>
  <div>B</div>
  <div>C</div>
</div>
medium
A. Two columns with A and B in first row, C alone in second row
B. Three columns in one row with A, B, C
C. One column with A, B, C stacked vertically
D. Grid with no gaps and all items overlapping

Solution

  1. Step 1: Understand grid-cols-2 and gap-4

    The class grid-cols-2 creates 2 columns, and gap-4 adds space between items.
  2. Step 2: Place items in grid

    Items fill rows left to right: A and B in first row, C starts second row alone.
  3. Final Answer:

    Two columns with A and B in first row, C alone in second row -> Option A
  4. Quick Check:

    2 columns + 3 items = 2 in first row, 1 in second [OK]
Hint: Items fill rows left to right in grid-cols-N [OK]
Common Mistakes:
  • Assuming all items fit in one row
  • Ignoring gap spacing effect
  • Thinking grid-cols-2 means 3 columns
4. Identify the error in this Tailwind grid layout code:
<div class="grid grid-cols-3 gap-2">
  <div class="col-span-4">Item</div>
</div>
medium
A. gap-2 is not a valid Tailwind class
B. col-span-4 is invalid because grid has only 3 columns
C. grid-cols-3 should be grid-rows-3
D. Missing closing tag for div

Solution

  1. Step 1: Check grid column count

    The grid has 3 columns set by grid-cols-3.
  2. Step 2: Validate col-span value

    col-span-4 tries to span 4 columns, which is more than available 3 columns, causing layout error.
  3. Final Answer:

    col-span-4 is invalid because grid has only 3 columns -> Option B
  4. Quick Check:

    Span cannot exceed total columns [OK]
Hint: Span number must not exceed grid columns [OK]
Common Mistakes:
  • Using col-span larger than columns
  • Confusing gap class validity
  • Misreading grid-cols as rows
5. You want a responsive layout with 4 columns on large screens and 2 columns on small screens using Tailwind. Which code correctly achieves this?
hard
A.
...
B.
...
C.
...
D.
...

Solution

  1. Step 1: Understand responsive prefixes

    In Tailwind, lg: prefix applies styles on large screens and above.
  2. Step 2: Check column classes for responsiveness

    grid-cols-2 sets 2 columns by default (small screens), lg:grid-cols-4 changes to 4 columns on large screens.
  3. Final Answer:

    <div class="grid grid-cols-2 lg:grid-cols-4 gap-6">...</div> -> Option D
  4. Quick Check:

    Default 2 cols, large screens 4 cols [OK]
Hint: Use lg: prefix for large screen overrides [OK]
Common Mistakes:
  • Reversing small and large screen classes
  • Missing grid class for display
  • Using grid-rows instead of grid-cols
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard