Bird
Raised Fist0
Tailwindmarkup~10 mins

Grid container activation 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 activate 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'
Aflex
Bblock
Cinline
Dgrid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'flex' instead of 'grid' activates flexbox, not grid.
Using 'block' or 'inline' does not create a grid container.
2fill in blank
medium

Complete the code to create a grid container with 3 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-3
Bgrid-cols-2
Cgrid-rows-3
Dgrid-flow-col
Attempts:
3 left
💡 Hint
Common Mistakes
Using grid-cols-2 creates only 2 columns.
Using grid-rows-3 sets rows, not columns.
Using grid-flow-col changes flow direction, not column count.
3fill in blank
hard

Fix the error in the code to properly activate a grid container with 4 columns.

Tailwind
<section class="[1] grid-cols-4 gap-3">
  <article>Content A</article>
  <article>Content B</article>
  <article>Content C</article>
  <article>Content D</article>
</section>
Drag options to blanks, or click blank then click option'
Agrid
Bblock
Cinline-grid
Dflex
Attempts:
3 left
💡 Hint
Common Mistakes
Using flex activates flexbox, not grid.
Using inline-grid is valid but not the intended answer here.
Using block does not activate grid.
4fill in blank
hard

Fill both blanks to create a grid container with 2 rows and a gap of 6.

Tailwind
<div class="[1] [2] gap-6">
  <div>Row 1</div>
  <div>Row 2</div>
</div>
Drag options to blanks, or click blank then click option'
Agrid
Bgrid-cols-1
Cgrid-rows-2
Dflex
Attempts:
3 left
💡 Hint
Common Mistakes
Using flex instead of grid.
Using grid-cols-1 sets columns, not rows.
5fill in blank
hard

Fill all three blanks to create a grid container with 3 columns, 2 rows, and a gap of 4.

Tailwind
<section class="[1] [2] [3] grid-rows-2">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
  <div>Item 4</div>
  <div>Item 5</div>
  <div>Item 6</div>
</section>
Drag options to blanks, or click blank then click option'
Agrid
Bgrid-cols-3
Cgrid-rows-2
Dgap-4
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to activate grid with grid.
Mixing up rows and columns classes.
Using wrong gap size class.

Practice

(1/5)
1. What does adding the grid class to a container do in Tailwind CSS?
easy
A. It makes the container scrollable horizontally.
B. It hides the container from view.
C. It activates the grid layout, allowing items to be arranged in rows and columns.
D. It changes the container's background color to gray.

Solution

  1. Step 1: Understand the role of the grid class

    The grid class in Tailwind CSS activates CSS Grid layout on the container.
  2. Step 2: Recognize the effect on child items

    Once activated, child elements can be arranged in rows and columns easily using grid properties.
  3. Final Answer:

    It activates the grid layout, allowing items to be arranged in rows and columns. -> Option C
  4. Quick Check:

    Grid class activates grid layout [OK]
Hint: Grid class means container uses rows and columns layout [OK]
Common Mistakes:
  • Confusing grid with flex layout
  • Thinking grid hides the container
  • Assuming grid changes colors automatically
2. Which of the following is the correct way to activate a grid container in Tailwind CSS?
easy
A. <div class='grid'>
B. <div class='grid-container'>
C. <div class='container-grid'>
D. <div class='grid-layout'>

Solution

  1. Step 1: Recall Tailwind's grid activation class

    Tailwind uses the simple class grid to activate grid layout on a container.
  2. Step 2: Check the options for exact class name

    Only <div class='grid'> uses the exact class grid without extra words or hyphens.
  3. Final Answer:

    <div class='grid'> -> Option A
  4. Quick Check:

    Use class 'grid' to activate grid [OK]
Hint: Use exactly 'grid' class to activate grid container [OK]
Common Mistakes:
  • Adding extra words like 'container' or 'layout'
  • Using incorrect class names not in Tailwind
  • Confusing grid with flex classes
3. Given this HTML snippet:
<div class='grid grid-cols-3 gap-4'>
  <div>A</div>
  <div>B</div>
  <div>C</div>
  <div>D</div>
</div>

How will the items be arranged visually?
medium
A. Four items stacked vertically with no gaps.
B. Four items arranged in 3 columns and 2 rows with gaps between them.
C. Four items arranged in a single row with no gaps.
D. Four items arranged randomly with overlapping.

Solution

  1. Step 1: Understand the grid classes used

    The class grid activates grid layout. grid-cols-3 sets 3 columns. gap-4 adds space between grid items.
  2. Step 2: Visualize item placement

    With 4 items and 3 columns, the first row has 3 items (A, B, C), second row has 1 item (D). Gaps appear between items.
  3. Final Answer:

    Four items arranged in 3 columns and 2 rows with gaps between them. -> Option B
  4. Quick Check:

    grid-cols-3 + 4 items = 2 rows, gaps present [OK]
Hint: grid-cols-3 means 3 columns, items fill rows left to right [OK]
Common Mistakes:
  • Assuming all items fit in one row
  • Ignoring the gap class effect
  • Thinking items overlap or stack vertically
4. Identify the error in this Tailwind grid container code:
<div class='grid-cols-4 gap-2'>
  <div>1</div>
  <div>2</div>
</div>
medium
A. Missing the grid class to activate grid layout.
B. Using gap-2 without specifying columns.
C. Too few child elements for 4 columns.
D. Incorrect use of div tags inside grid.

Solution

  1. Step 1: Check for grid activation class

    The code uses grid-cols-4 and gap-2 but misses the essential grid class to activate grid layout.
  2. Step 2: Understand effect of missing grid class

    Without grid, the container behaves like a normal block, ignoring grid columns and gaps.
  3. Final Answer:

    Missing the grid class to activate grid layout. -> Option A
  4. Quick Check:

    Always include 'grid' class to enable grid [OK]
Hint: Always add 'grid' class before columns or gap classes [OK]
Common Mistakes:
  • Forgetting to add 'grid' class
  • Thinking gap works without grid
  • Assuming columns work alone
5. You want to create a responsive grid container that has 2 columns on small screens and 4 columns on medium and larger screens using Tailwind CSS. Which class combination should you use?
hard
A. grid grid-cols-4 sm:grid-cols-2 gap-3
B. grid-cols-2 md:grid-cols-4 gap-3
C. grid grid-cols-2 sm:grid-cols-4 gap-3
D. grid grid-cols-2 md:grid-cols-4 gap-3

Solution

  1. Step 1: Understand Tailwind responsive prefixes

    In Tailwind, md: prefix applies styles at medium screen sizes and above. So md:grid-cols-4 sets 4 columns on medium+ screens.
  2. Step 2: Set default and responsive columns

    Default grid-cols-2 applies on small screens. Combined with md:grid-cols-4, it changes to 4 columns on medium+ screens.
  3. Final Answer:

    grid grid-cols-2 md:grid-cols-4 gap-3 -> Option D
  4. Quick Check:

    Use 'md:' prefix for medium screen columns [OK]
Hint: Use 'md:' prefix for medium screens, default for small [OK]
Common Mistakes:
  • Swapping sm and md prefixes incorrectly
  • Placing grid-cols classes in wrong order
  • Omitting the 'grid' class
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