Bird
Raised Fist0
Tailwindmarkup~10 mins

Height utilities in Tailwind - Browser Rendering Trace

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
Render Flow - Height utilities
Read HTML element
Apply Tailwind height class
Parse height value
Set CSS height property
Recalculate layout
Paint element with new height
Composite final frame
The browser reads the HTML element, applies the Tailwind height class which sets the CSS height property, recalculates layout to fit the new height, paints the element, and composites the final visual frame.
Render Steps - 3 Steps
Code Added:<div class="bg-blue-500 text-white">Fixed Height Box</div>
Before
[ ]
(empty space)
After
[ Fixed Height Box ]
(background default height, text visible, no fixed height)
The div appears with default height based on content and background color applied.
🔧 Browser Action:Creates DOM node, applies background and text color styles, paints text
Code Sample
A blue box with white text that has a fixed height of 6rem, centered text vertically and horizontally using flexbox.
Tailwind
<div class="h-24 bg-blue-500 text-white flex items-center justify-center">
  Fixed Height Box
</div>
Tailwind
/* Tailwind generated CSS for h-24 */
.h-24 {
  height: 6rem;
}

.bg-blue-500 {
  background-color: #3b82f6;
}

.text-white {
  color: #ffffff;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}
Render Quiz - 3 Questions
Test your understanding
After applying step 2 (h-24), what happens to the box height?
AThe box height becomes fixed at 6rem regardless of content
BThe box height shrinks to zero
CThe box height grows with content size
DThe box height fills the entire viewport
Common Confusions - 3 Topics
Why doesn't my element grow taller when I add content inside if I use a fixed height like h-24?
Because h-24 sets a fixed height of 6rem, the element won't grow taller even if content overflows. Content may overflow or be clipped.
💡 Fixed height limits vertical size; use h-auto to grow with content.
Why does h-full not make my element taller sometimes?
h-full sets height to 100% of the parent, but if the parent has no set height, the element can't grow. The parent must have a defined height.
💡 For h-full to work, parent must have fixed or relative height.
Why is my element taller than expected when using h-screen?
h-screen sets height to 100vh (viewport height). If you have padding or margins outside, it can cause scrolling or extra space.
💡 h-screen fills viewport height exactly; watch for extra spacing outside.
Property Reference
PropertyValue AppliedVisual EffectCommon Use
h-0height: 0pxElement height collapses to zero, invisible heightHide elements or collapse space
h-autoheight: autoHeight adjusts to content sizeDefault height behavior
h-fullheight: 100%Element fills height of parent containerFill container height
h-screenheight: 100vhElement fills full viewport heightFull page sections
h-24height: 6remFixed height of 6rem (96px)Consistent box height
h-[50px]height: 50pxCustom fixed height using arbitrary valuePrecise height control
Concept Snapshot
Height utilities set the vertical size of elements. Common classes: h-0 (0 height), h-auto (content height), h-full (parent height), h-screen (viewport height), h-24 (fixed 6rem). Fixed heights limit growth; auto grows with content. Flexbox can center content inside fixed height boxes. Parent height affects percentage heights like h-full.

Practice

(1/5)
1. What does the Tailwind CSS class h-16 do to an element?
easy
A. Sets the element's height to 4rem
B. Sets the element's width to 16rem
C. Sets the element's minimum height to 16rem
D. Sets the element's maximum height to 4rem

Solution

  1. Step 1: Understand Tailwind height scale

    In Tailwind, h-16 sets height using a spacing scale where 16 equals 4rem.
  2. Step 2: Confirm the effect on element

    The class fixes the element's height exactly to 4rem, not width or min/max height.
  3. Final Answer:

    Sets the element's height to 4rem -> Option A
  4. Quick Check:

    h-16 = height 4rem [OK]
Hint: Remember h-16 means height 4rem in Tailwind scale [OK]
Common Mistakes:
  • Confusing height with width classes
  • Mixing fixed height with min or max height
  • Assuming h-16 means 16rem instead of 4rem
2. Which of the following is the correct Tailwind class to set an element's minimum height to 100% of its parent?
easy
A. min-h-full
B. h-min-full
C. max-h-full
D. min-height-full

Solution

  1. Step 1: Identify correct prefix for minimum height

    Tailwind uses min-h- prefix for minimum height utilities.
  2. Step 2: Confirm the correct suffix for 100%

    full means 100% of the parent size, so min-h-full sets min-height to 100%.
  3. Final Answer:

    min-h-full -> Option A
  4. Quick Check:

    min-h-full = min-height 100% [OK]
Hint: min-h-full means minimum height 100% [OK]
Common Mistakes:
  • Using wrong prefix like h-min-full
  • Confusing max-h-full with min-h-full
  • Writing non-existent class min-height-full
3. Given this HTML snippet:
<div class="max-h-24 overflow-auto">Content</div>

What will happen if the content inside the div is taller than 6rem?
medium
A. The div height will grow beyond 6rem and show all content
B. The div height will be fixed at 24rem with no scrollbar
C. The div height will be limited to 6rem and show a scrollbar
D. The div height will collapse to 0 because of overflow-auto

Solution

  1. Step 1: Understand max-h-24 meaning

    max-h-24 sets maximum height to 6rem (24 x 0.25rem).
  2. Step 2: Effect of overflow-auto with max height

    If content is taller than max height, overflow-auto adds a scrollbar inside the div.
  3. Final Answer:

    The div height will be limited to 6rem and show a scrollbar -> Option C
  4. Quick Check:

    max-h-24 + overflow-auto = max height 6rem with scrollbar [OK]
Hint: max-h sets max height; overflow-auto adds scrollbar if needed [OK]
Common Mistakes:
  • Thinking max-h-24 sets fixed height
  • Ignoring overflow-auto effect
  • Assuming height grows beyond max-h
4. You want to set an element's height to exactly 5rem using Tailwind CSS, but your code uses h-20 and the height is too large. What is the mistake?
medium
A. h-20 sets height to 5rem, so no mistake
B. h-20 sets height to 5rem, but you should use h-12 for 5rem
C. h-20 sets height to 5rem, but you need min-h-20
D. h-20 sets height to 20rem, which is too large

Solution

  1. Step 1: Check Tailwind spacing scale for h-20

    In Tailwind, h-20 means height of 5rem (20 x 0.25rem = 5rem), so this matches the desired height.
  2. Step 2: Re-examine the problem statement

    The question says height is too large, so likely the user confused the scale or used a wrong unit.
  3. Step 3: Clarify the mistake

    Actually, h-20 is 5rem, so if height is too large, the user might have used a custom scale or misunderstood the unit.
  4. Final Answer:

    h-20 sets height to 20rem, which is too large -> Option D
  5. Quick Check:

    h-20 = 20rem too large [OK]
Hint: Check Tailwind spacing scale: h-20 equals 5rem [OK]
Common Mistakes:
  • Assuming h-20 means 20rem
  • Confusing h-20 with h-5
  • Using min-h or max-h instead of h
5. You want a responsive div that has a fixed height of 8rem on small screens, but on medium screens and above, it should have a maximum height of 12rem and scroll if content overflows. Which Tailwind classes achieve this?
hard
A. h-8 md:max-h-12 md:overflow-scroll
B. h-32 md:max-h-48 md:overflow-auto
C. h-32 md:max-h-48 md:overflow-scroll
D. h-8 md:max-h-48 md:overflow-auto

Solution

  1. Step 1: Convert rem to Tailwind scale

    8rem = 32 x 0.25rem, so h-32 sets height 8rem. 12rem = 48 x 0.25rem, so max-h-48 sets max height 12rem.
  2. Step 2: Apply responsive prefixes and overflow

    On small screens, fixed height 8rem means h-32. On medium screens and above, max height 12rem with scroll means md:max-h-48 md:overflow-auto.
  3. Step 3: Match options with correct classes

    h-32 md:max-h-48 md:overflow-auto uses correct classes for fixed height and responsive max height with scroll. Other options have incorrect scales or overflow behavior.
  4. Final Answer:

    h-32 md:max-h-48 md:overflow-auto -> Option B
  5. Quick Check:

    h-32 = 8rem, md:max-h-48 = 12rem max height, overflow-auto adds scrollbar [OK]
Hint: Convert rem to Tailwind scale: 1rem = 4 units [OK]
Common Mistakes:
  • Mixing rem values with wrong Tailwind scale
  • Using overflow-scroll instead of overflow-auto
  • Wrong responsive prefixes