Bird
Raised Fist0
Tailwindmarkup~10 mins

Why display modes matter in Tailwind - Test Your Understanding

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to make the container a flexbox using Tailwind CSS.

Tailwind
<div class="[1] p-4 bg-gray-100">
  <p>This is a flex container.</p>
</div>
Drag options to blanks, or click blank then click option'
Aflex
Bgrid
Cinline
Dblock
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'block' which is the default display mode and does not create a flex container.
Using 'inline' which makes the element inline, not a flex container.
2fill in blank
medium

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

Tailwind
<section class="[1] gap-4 p-4">
  <div>Item 1</div>
  <div>Item 2</div>
</section>
Drag options to blanks, or click blank then click option'
Aflex
Bblock
Cinline-block
Dgrid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'flex' which creates a flex container, not a grid.
Using 'block' which is the default display mode.
3fill in blank
hard

Fix the error in the code by choosing the correct display class to center items horizontally in a flex container.

Tailwind
<div class="flex [1] items-center h-32 bg-blue-100">
  <p>Centered content</p>
</div>
Drag options to blanks, or click blank then click option'
Aitems-start
Bjustify-start
Cjustify-center
Dcontent-center
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'justify-start' which aligns items to the start, not center.
Using 'items-start' which aligns items vertically, not horizontally.
4fill in blank
hard

Fill both blanks to create a responsive grid with 3 columns on medium screens and gap between items.

Tailwind
<div class="[1] [2] gap-6 p-4">
  <div class="bg-green-200 p-2">Box 1</div>
  <div class="bg-green-200 p-2">Box 2</div>
  <div class="bg-green-200 p-2">Box 3</div>
</div>
Drag options to blanks, or click blank then click option'
Agrid
Bflex
Cmd:grid-cols-3
Dmd:flex-row
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'flex' instead of 'grid' for grid layout.
Using 'md:flex-row' which is for flexbox, not grid columns.
5fill in blank
hard

Fill all three blanks to create a flex container that stacks items vertically on small screens and horizontally on large screens with spacing.

Tailwind
<div class="flex [1] [2] [3] gap-4 p-4">
  <div class="bg-yellow-200 p-2">Item A</div>
  <div class="bg-yellow-200 p-2">Item B</div>
</div>
Drag options to blanks, or click blank then click option'
Aflex-col
Blg:flex-row
Citems-center
Djustify-between
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'flex-row' instead of 'flex-col' for default vertical stacking.
Forgetting to add responsive prefix 'lg:' for horizontal layout on large screens.

Practice

(1/5)
1. Which Tailwind class makes an element behave like a block-level element, taking full width by default?
easy
A. block
B. inline
C. inline-flex
D. hidden

Solution

  1. Step 1: Understand block display behavior

    A block element takes the full width available and starts on a new line.
  2. Step 2: Match Tailwind class to behavior

    The block class in Tailwind applies this block display mode.
  3. Final Answer:

    <code>block</code> -> Option A
  4. Quick Check:

    Block display = block class [OK]
Hint: Block elements use block class for full width [OK]
Common Mistakes:
  • Confusing inline with block display
  • Thinking flex is block by default
  • Assuming hidden shows the element
2. Which Tailwind class correctly hides an element from the page?
easy
A. hidden
B. block
C. visible
D. flex

Solution

  1. Step 1: Identify the class that hides elements

    The hidden class in Tailwind sets display: none;, hiding the element.
  2. Step 2: Confirm other classes show elements

    visible is not a Tailwind display class, block and flex show elements.
  3. Final Answer:

    <code>hidden</code> -> Option A
  4. Quick Check:

    Hide element = hidden class [OK]
Hint: Use hidden to hide elements in Tailwind [OK]
Common Mistakes:
  • Using visible which is not a Tailwind display class
  • Confusing block or flex as hiding classes
  • Trying to hide with opacity or visibility classes only
3. What will be the layout behavior of this element with Tailwind classes: inline flex?
medium
A. The element behaves as a block and its children are flex items.
B. The element behaves as a flex container and takes full width.
C. The element is hidden because conflicting display classes cancel out.
D. The element behaves inline but also applies flex layout to its children.

Solution

  1. Step 1: Understand Tailwind display class precedence

    Tailwind applies the last display class in the list, so flex overrides inline.
  2. Step 2: Check combined classes effect

    However, if both are applied, the element behaves as a flex container, but if inline is applied first and flex second, it becomes a flex container with block behavior.
  3. Step 3: Clarify the question's class order

    Since classes are inline flex, flex overrides inline, so element behaves as flex container (block-level).
  4. Final Answer:

    The element behaves as a flex container and takes full width. -> Option B
  5. Quick Check:

    Last display class wins = flex container [OK]
Hint: Last display class in Tailwind wins [OK]
Common Mistakes:
  • Thinking multiple display classes combine effects
  • Assuming inline and flex can coexist
  • Ignoring class order importance
4. You want a container to arrange children horizontally using Tailwind, but your code uses block and children stack vertically. What is the mistake?
medium
A. Using flex on children instead of container
B. Not adding inline to children
C. Forgetting to add hidden to children
D. Using block instead of flex on the container

Solution

  1. Step 1: Understand display modes for layout

    block makes container stack children vertically by default.
  2. Step 2: Use flex for horizontal layout

    To arrange children horizontally, container must have flex display.
  3. Final Answer:

    Using block instead of flex on the container -> Option D
  4. Quick Check:

    Horizontal layout needs flex container [OK]
Hint: Use flex on container for horizontal layout [OK]
Common Mistakes:
  • Applying flex to children instead of container
  • Thinking inline arranges children horizontally
  • Not understanding block stacks vertically
5. You want a button to be inline with text but also have flex layout inside to center icon and label. Which Tailwind classes correctly achieve this?
hard
A. inline-block flex justify-between
B. block flex justify-center
C. inline-flex items-center
D. flex inline items-start

Solution

  1. Step 1: Make button inline with text

    The inline-flex class makes the button flow inline with text.
  2. Step 2: Apply flex layout inside button

    The inline-flex class makes the button a flex container for its children.
  3. Step 3: Center icon and label vertically

    items-center aligns children vertically center inside flex container.
  4. Final Answer:

    <code>inline-flex items-center</code> -> Option C
  5. Quick Check:

    Inline + flex + center items = inline-flex items-center [OK]
Hint: Use inline-flex items-center for inline flex centering [OK]
Common Mistakes:
  • Using block makes button block-level, breaking inline flow
  • Wrong order or missing items-center for vertical alignment
  • Using justify-between instead of centering