Bird
Raised Fist0
Tailwindmarkup~20 mins

Flex container activation in Tailwind - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Flexbox Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does flex class do in Tailwind CSS?
In Tailwind CSS, what is the effect of adding the flex class to a container element?
AIt sets the container's display property to <code>flex</code>, enabling flexbox layout.
BIt adds margin and padding to the container for spacing.
CIt changes the container's position to <code>absolute</code>.
DIt applies a grid layout to the container.
Attempts:
2 left
💡 Hint
Think about how flexbox layouts start in CSS.
📝 Syntax
intermediate
1:30remaining
Which Tailwind class activates flexbox on a container?
You want to make a <div> a flex container using Tailwind CSS. Which class should you add?
Tailwind
<div class="???">
  <p>Item 1</p>
  <p>Item 2</p>
</div>
Agrid
Bflex
Cblock
Dinline
Attempts:
2 left
💡 Hint
The class name matches the CSS display property value.
❓ rendering
advanced
2:30remaining
What is the visual result of adding flex to a container with multiple children?
Given this HTML and Tailwind CSS, what will you see in the browser?
Tailwind
<div class="flex border border-gray-400 p-4">
  <div class="bg-blue-500 text-white p-2">Box 1</div>
  <div class="bg-green-500 text-white p-2">Box 2</div>
  <div class="bg-red-500 text-white p-2">Box 3</div>
</div>
AOnly one colored box visible because others are hidden.
BThree colored boxes stacked vertically inside a bordered container.
CThree colored boxes overlapping each other inside a bordered container.
DThree colored boxes arranged side by side in a row inside a bordered container.
Attempts:
2 left
💡 Hint
Flexbox default direction is row.
❓ selector
advanced
2:00remaining
Which Tailwind class combination makes a flex container with vertical stacking?
You want a flex container that stacks its children vertically. Which class combination achieves this?
Ablock flex-col
Bflex flex-row
Cflex flex-col
Dgrid grid-cols-1
Attempts:
2 left
💡 Hint
Flex direction controls stacking direction.
❓ accessibility
expert
3:00remaining
How to ensure keyboard users can navigate flex container items properly?
You have a flex container with interactive child elements. What is the best practice to ensure keyboard accessibility?
AEnsure each child element is focusable with <code>tabindex</code> or native focus, and use semantic HTML elements.
BAdd <code>aria-hidden="true"</code> to all child elements to hide them from screen readers.
CUse only <code>div</code> elements without any focus or ARIA attributes.
DDisable keyboard navigation by setting <code>tabindex="-1"</code> on all children.
Attempts:
2 left
💡 Hint
Think about how keyboard users interact with page elements.

Practice

(1/5)
1. What does adding the Tailwind class flex to a container do?
easy
A. It activates the flexbox layout on that container.
B. It hides the container from view.
C. It adds a fixed width to the container.
D. It changes the container's background color.

Solution

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

    The flex class in Tailwind activates the flexbox layout on the container, enabling flexible arrangement of child items.
  2. Step 2: Compare other options

    Other options describe unrelated effects like hiding, fixed width, or color change, which flex does not do.
  3. Final Answer:

    It activates the flexbox layout on that container. -> Option A
  4. Quick Check:

    Adding flex = activates flexbox [OK]
Hint: Remember: flex turns on flexbox layout [OK]
Common Mistakes:
  • Thinking flex hides the container
  • Confusing flex with width or color classes
  • Assuming flex only styles text
2. Which of the following is the correct Tailwind syntax to activate flexbox on a container?
easy
A. flex
B. flexbox
C. flex-container
D. flex-layout

Solution

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

    The correct class to activate flexbox in Tailwind is exactly flex.
  2. Step 2: Check other options for validity

    Classes like flexbox, flex-container, and flex-layout do not exist in Tailwind.
  3. Final Answer:

    flex -> Option A
  4. Quick Check:

    Correct class = flex [OK]
Hint: Use exactly flex to enable flexbox [OK]
Common Mistakes:
  • Adding extra words like 'box' or 'container' to flex
  • Using incorrect class names not in Tailwind
  • Confusing with CSS property names
3. Given this HTML snippet:
<div class="flex flex-col">
  <div>Item 1</div>
  <div>Item 2</div>
</div>

How will the items be arranged visually?
medium
A. Items will be hidden.
B. Items will be arranged side by side in a row.
C. Items will overlap each other.
D. Items will be stacked vertically in a column.

Solution

  1. Step 1: Understand the effect of flex and flex-col

    The flex class activates flexbox, and flex-col sets the direction to column, stacking items vertically.
  2. Step 2: Visualize the layout

    Because of flex-col, the two divs appear one below the other, not side by side or overlapping.
  3. Final Answer:

    Items will be stacked vertically in a column. -> Option D
  4. Quick Check:

    flex-col = vertical stack [OK]
Hint: Use flex-col for vertical stacking [OK]
Common Mistakes:
  • Assuming default flex direction is column without flex-col
  • Thinking items overlap without positioning
  • Confusing row and column directions
4. What is wrong with this Tailwind code if the container does not behave as a flex container?
<div class="flex-col">
  <div>A</div>
  <div>B</div>
</div>
medium
A. The container needs block class to work.
B. The class flex-col should be flex-row to activate flexbox.
C. The class flex-col alone does not activate flexbox; flex is missing.
D. The child divs need flex class, not the container.

Solution

  1. Step 1: Check if flexbox is activated

    The class flex-col only sets direction but does not activate flexbox. The flex class is required to enable flexbox.
  2. Step 2: Verify other options

    flex-row sets direction but also requires flex. block is default display, and child divs do not need flex.
  3. Final Answer:

    The class flex-col alone does not activate flexbox; flex is missing. -> Option C
  4. Quick Check:

    Missing flex means no flexbox [OK]
Hint: Always add flex to activate flexbox before direction [OK]
Common Mistakes:
  • Using flex-col without flex
  • Thinking flex-col alone activates flexbox
  • Adding flex to children instead of container
5. You want a container to arrange items in a row but wrap to the next line if they don't fit. Which Tailwind classes should you add?
hard
A. flex-col flex-wrap
B. flex flex-wrap
C. flex flex-nowrap
D. block flex-wrap

Solution

  1. Step 1: Activate flexbox and set wrapping

    Use flex to activate flexbox with default row direction, and flex-wrap to allow items to wrap to the next line.
  2. Step 2: Eliminate incorrect options

    flex-col sets column direction, not row. flex-nowrap disables wrapping. block is not flexbox.
  3. Final Answer:

    flex flex-wrap -> Option B
  4. Quick Check:

    Row + wrap = flex flex-wrap [OK]
Hint: Combine flex and flex-wrap for wrapping rows [OK]
Common Mistakes:
  • Using flex-col when row is needed
  • Using flex-nowrap which disables wrapping
  • Using block instead of flex
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