Bird
Raised Fist0
Tailwindmarkup~10 mins

Block, inline, and inline-block in Tailwind - Interactive Code Practice

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 element a block-level element using Tailwind CSS.

Tailwind
<div class="[1]">This is a block element.</div>
Drag options to blanks, or click blank then click option'
Ablock
Binline
Cinline-block
Dflex
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inline' or 'inline-block' instead of 'block' will not make the element block-level.
2fill in blank
medium

Complete the code to make the element display inline using Tailwind CSS.

Tailwind
<span class="[1]">This is an inline element.</span>
Drag options to blanks, or click blank then click option'
Ainline
Bblock
Cinline-block
Dgrid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'block' will make the element start on a new line.
Using 'inline-block' allows width and height but is not purely inline.
3fill in blank
hard

Fix the error in the code to make the element display as inline-block using Tailwind CSS.

Tailwind
<button class="[1]">Click me</button>
Drag options to blanks, or click blank then click option'
Ablock
Binline
Cinline-block
Dflex
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inline' will not allow width and height to be set.
Using 'block' will make the element start on a new line.
4fill in blank
hard

Fill both blanks to create a list where items are inline-block and the container is block-level.

Tailwind
<ul class="[1]">
  <li class="[2]">Item 1</li>
  <li class="inline-block">Item 2</li>
</ul>
Drag options to blanks, or click blank then click option'
Ablock
Binline
Cinline-block
Dflex
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inline' on list items will not allow width or height control.
Using 'inline' on the container will break the list layout.
5fill in blank
hard

Fill all three blanks to create a navigation bar where the container is block, links are inline-block, and the active link is inline.

Tailwind
<nav class="[1]">
  <a href="#" class="[2]">Home</a>
  <a href="#" class="[3]">About</a>
</nav>
Drag options to blanks, or click blank then click option'
Ablock
Binline-block
Cinline
Dflex
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'flex' on container changes layout behavior.
Using 'block' on links makes them stack vertically.

Practice

(1/5)
1. Which Tailwind class makes an element behave like a block element that breaks the line and fills the container width?
easy
A. block
B. inline
C. inline-block
D. flex

Solution

  1. Step 1: Understand block element behavior

    Block elements start on a new line and take full container width.
  2. Step 2: Match Tailwind class to behavior

    The Tailwind class block applies this behavior.
  3. Final Answer:

    block -> Option A
  4. Quick Check:

    Block = block [OK]
Hint: Block elements use block class in Tailwind [OK]
Common Mistakes:
  • Confusing inline with block behavior
  • Using inline-block which does not break line
  • Choosing flex which is for flexbox layout
2. Which Tailwind class correctly applies inline-block display to an element?
easy
A. inline-block
B. hidden
C. block
D. inline

Solution

  1. Step 1: Recall Tailwind display classes

    inline-block is the class that sets display to inline-block.
  2. Step 2: Confirm class matches inline-block behavior

    Inline-block elements flow inline but can have width and height.
  3. Final Answer:

    inline-block -> Option A
  4. Quick Check:

    Inline-block = inline-block [OK]
Hint: Use inline-block class for inline-block display [OK]
Common Mistakes:
  • Using inline which lacks block sizing
  • Choosing block which breaks line
  • Selecting hidden which hides element
3. What will be the visual layout of these two elements with Tailwind classes?
<div class="block bg-blue-300 p-2">Block</div>
<span class="inline bg-red-300 p-2">Inline</span>
medium
A. Red inline element breaks line and appears below block
B. Both elements appear on the same line side by side
C. Both elements hidden due to conflicting classes
D. Block element on its own line, red inline text flows next to it

Solution

  1. Step 1: Understand block element behavior

    The div with block class breaks line and fills width.
  2. Step 2: Understand inline element behavior

    The span with inline class flows inline, so it appears next to following text if space allows.
  3. Final Answer:

    Block element on its own line, red inline text flows next to it -> Option D
  4. Quick Check:

    Block breaks line, inline flows inline [OK]
Hint: Block breaks line; inline stays inline [OK]
Common Mistakes:
  • Thinking inline breaks line like block
  • Assuming both appear side by side
  • Confusing element types and classes
4. You want an element to flow inline but also set width and height. Which Tailwind class is incorrectly used here?
<div class="inline w-32 h-16 bg-green-300">Box</div>
medium
A. w-32 is invalid for inline elements
B. inline is incorrect because width and height won't apply properly
C. h-16 causes syntax error with inline
D. bg-green-300 hides the element

Solution

  1. Step 1: Understand inline element sizing

    Inline elements ignore width and height properties.
  2. Step 2: Identify class causing issue

    The inline class causes the element to behave inline, so width and height won't apply.
  3. Final Answer:

    inline is incorrect because width and height won't apply properly -> Option B
  4. Quick Check:

    Inline ignores width/height [OK]
Hint: Inline ignores width/height; use inline-block instead [OK]
Common Mistakes:
  • Thinking width/height work on inline
  • Blaming width or height classes
  • Confusing background color with visibility
5. You want two buttons side by side with padding and fixed size, but they should not break lines. Which Tailwind classes combination is best?
<button class="?">Btn 1</button>
<button class="?">Btn 2</button>
hard
A. inline w-24 h-10 p-2 bg-blue-500 text-white
B. block w-24 h-10 p-2 bg-blue-500 text-white
C. inline-block w-24 h-10 p-2 bg-blue-500 text-white
D. hidden w-24 h-10 p-2 bg-blue-500 text-white

Solution

  1. Step 1: Identify display needed for side-by-side buttons

    Buttons should flow inline but keep size and padding, so inline-block is needed.
  2. Step 2: Check other classes for size and style

    w-24 and h-10 set fixed size, p-2 adds padding, and colors style the buttons.
  3. Final Answer:

    inline-block w-24 h-10 p-2 bg-blue-500 text-white -> Option C
  4. Quick Check:

    Inline-block + size + padding = side-by-side buttons [OK]
Hint: Use inline-block for sized inline elements [OK]
Common Mistakes:
  • Using block breaks buttons into separate lines
  • Using inline ignores width and height
  • Using hidden hides buttons