Bird
Raised Fist0
Tailwindmarkup~10 mins

Column spanning in Tailwind - Interactive Code Practice

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

Complete the code to make the first grid item span 2 columns.

Tailwind
<div class="grid grid-cols-3 gap-4">
  <div class="[1]">Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
</div>
Drag options to blanks, or click blank then click option'
Acol-span-2
Bcol-start-2
Ccol-end-3
Dcol-span-3
Attempts:
3 left
💡 Hint
Common Mistakes
Using col-start-2 only changes the start column, not the span.
Using col-end-3 is about ending position, not span.
Using col-span-3 spans all columns, not 2.
2fill in blank
medium

Complete the code to make the second grid item span 3 columns.

Tailwind
<div class="grid grid-cols-4 gap-2">
  <div>Item 1</div>
  <div class="[1]">Item 2</div>
  <div>Item 3</div>
  <div>Item 4</div>
</div>
Drag options to blanks, or click blank then click option'
Acol-span-2
Bcol-start-3
Ccol-span-4
Dcol-span-3
Attempts:
3 left
💡 Hint
Common Mistakes
Using col-span-2 spans fewer columns than needed.
Using col-span-4 spans all columns, not 3.
Using col-start-3 only changes start position.
3fill in blank
hard

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

Tailwind
<div class="grid grid-cols-3 gap-3">
  <div>Item 1</div>
  <div>Item 2</div>
  <div class="[1]">Item 3</div>
</div>
Drag options to blanks, or click blank then click option'
Acol-span-2
Bcol-span-4
Ccol-start-2
Dcol-end-3
Attempts:
3 left
💡 Hint
Common Mistakes
Using col-span-4 in a 3-column grid causes layout issues.
Using col-start-2 only changes start position.
Using col-end-3 is not for spanning columns.
4fill in blank
hard

Fill both blanks to make the first item span 2 columns and the second item span 3 columns.

Tailwind
<div class="grid grid-cols-5 gap-4">
  <div class="[1]">Item 1</div>
  <div class="[2]">Item 2</div>
  <div>Item 3</div>
</div>
Drag options to blanks, or click blank then click option'
Acol-span-2
Bcol-span-4
Ccol-span-3
Dcol-start-2
Attempts:
3 left
💡 Hint
Common Mistakes
Using col-span-4 for the first item spans too many columns.
Using col-start-2 does not control span.
Mixing up the spans between items.
5fill in blank
hard

Fill all three blanks to create a grid where the first item spans 3 columns, the second item spans 1 column, and the third item spans 2 columns.

Tailwind
<div class="grid grid-cols-6 gap-2">
  <div class="[1]">Item 1</div>
  <div class="[2]">Item 2</div>
  <div class="[3]">Item 3</div>
</div>
Drag options to blanks, or click blank then click option'
Acol-span-3
Bcol-span-1
Ccol-span-2
Dcol-start-2
Attempts:
3 left
💡 Hint
Common Mistakes
Using col-start-2 instead of a span class.
Assigning wrong span numbers that don't add up.
Using the same span for all items.

Practice

(1/5)
1. What does the Tailwind class col-span-3 do in a grid layout?
easy
A. Creates 3 columns inside the element
B. Adds 3 columns to the grid container
C. Makes the element span across 3 columns in the grid
D. Sets the element width to 3rem

Solution

  1. Step 1: Understand the role of col-span-{n}

    The class col-span-3 tells the element to cover 3 columns in the grid layout.
  2. Step 2: Differentiate from other grid classes

    It does not create columns or set width; it only controls how many columns the element spans.
  3. Final Answer:

    Makes the element span across 3 columns in the grid -> Option C
  4. Quick Check:

    col-span-3 = span 3 columns [OK]
Hint: Remember col-span controls how many columns an item covers [OK]
Common Mistakes:
  • Confusing col-span with grid-cols which sets columns on container
  • Thinking col-span creates columns inside the element
  • Assuming col-span sets fixed width in rem or px
2. Which of the following is the correct way to make a grid container with 4 columns and an item that spans 2 columns in Tailwind?
easy
A.
Item
B.
Item
C.
Item
D.
Item

Solution

  1. Step 1: Set up the grid container with 4 columns

    The class grid-cols-4 inside a grid container creates 4 columns.
  2. Step 2: Make the item span 2 columns

    The class col-span-2 on the item makes it cover 2 columns.
  3. Final Answer:

    <div class='grid grid-cols-4'><div class='col-span-2'>Item</div></div> -> Option B
  4. Quick Check:

    grid-cols-4 + col-span-2 = correct syntax [OK]
Hint: Use grid-cols on container, col-span on item [OK]
Common Mistakes:
  • Swapping order of grid and grid-cols classes
  • Using incorrect class like span-col-2 instead of col-span-2
  • Setting col-span larger than grid-cols
3. Given this code snippet, what will be the visual layout of the grid items?
<div class='grid grid-cols-3 gap-4'>
  <div class='col-span-2 bg-blue-300'>A</div>
  <div class='bg-red-300'>B</div>
  <div class='bg-green-300'>C</div>
</div>
medium
A. Item A spans 2 columns in the first row, B occupies the third column in the first row, C starts a new row
B. Items A, B, and C all appear in the first row, each spanning one column
C. Item A spans 3 columns, B and C are below in separate rows
D. Item A spans 2 rows, B and C are side by side in the first row

Solution

  1. Step 1: Analyze grid container and columns

    The container has 3 columns with gaps. Item A spans 2 columns, so it fills columns 1 and 2 in the first row.
  2. Step 2: Position of items B and C

    Item B fills the remaining 1 column in the first row (column 3). Item C moves to the next row occupying the first column.
  3. Final Answer:

    Item A spans 2 columns in the first row, B occupies the third column in the first row, C starts a new row -> Option A
  4. Quick Check:

    col-span-2 + grid-cols-3 layout = Item A spans 2 columns in the first row, B occupies the third column in the first row, C starts a new row [OK]
Hint: Count columns and span to place items visually [OK]
Common Mistakes:
  • Assuming all items fit in one row regardless of span
  • Thinking col-span affects rows instead of columns
  • Ignoring grid gaps affecting spacing
4. Identify the error in this Tailwind grid code:
<div class='grid grid-cols-3'>
  <div class='col-span-4 bg-yellow-200'>Item 1</div>
  <div>Item 2</div>
</div>
medium
A. col-span-4 is invalid because the grid has only 3 columns
B. Missing gap class for spacing between columns
C. The grid container is missing the grid class
D. The second div should also have a col-span class

Solution

  1. Step 1: Check grid container columns

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

    The item uses col-span-4, which tries to span 4 columns, exceeding the 3 columns available.
  3. Final Answer:

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

    col-span cannot exceed grid-cols [OK]
Hint: col-span must be ≤ grid-cols count [OK]
Common Mistakes:
  • Ignoring that col-span cannot be larger than grid-cols
  • Thinking missing gap causes layout error
  • Assuming grid class is missing when it is present
5. You want to create a responsive grid where an item spans 4 columns on large screens but only 2 columns on small screens. Which Tailwind classes achieve this?
hard
A. grid grid-cols-6 col-span-2 sm:col-span-4
B. grid grid-cols-4 col-span-4 sm:col-span-2
C. grid grid-cols-6 col-span-4 sm:col-span-2
D. grid grid-cols-6 col-span-2 lg:col-span-4

Solution

  1. Step 1: Define grid with enough columns

    Using grid-cols-6 gives 6 columns, enough for spanning 4 columns on large screens.
  2. Step 2: Set default and large screen spans

    col-span-2 applies by default (small screens). lg:col-span-4 overrides on large screens to span 4 columns.
  3. Final Answer:

    grid grid-cols-6 col-span-2 lg:col-span-4 -> Option D
  4. Quick Check:

    Responsive col-span with lg: prefix = grid grid-cols-6 col-span-2 lg:col-span-4 [OK]
Hint: Use responsive prefixes like lg: for different spans [OK]
Common Mistakes:
  • Using sm: prefix for large screen changes
  • Setting col-span larger than grid-cols
  • Not defining enough columns in 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