Tailwind Height
Tailwind height utility provides a set of classes that enable you to set the height of an element to a specific value, percentages, or use predefined height utilities along with the default spacing scale.
Tailwind Height
Height utilities in Tailwind look simple at first glance, but they end up shaping a lot of real UI behavior: hero sections, scrollable panels, fixed headers, media containers, cards, and anything that needs predictable vertical sizing. The h-* scale offers straightforward values, but understanding when each type of height makes sense saves a lot of layout frustration later.
How to set Tailwind Height
The basic height class is h-{value}. Tailwind gives you a scale (h-0, h-4, h-64, etc.), plus a few special values:
-
h-{value}: This sets the height to a specific value in pixels. -
h-screen: This sets the height to the full height of the viewport. -
h-full: This sets the height to 100% of the parent container. -
h-auto: This sets the height to automatically adjust based on the content.
Below is the most straightforward example:
<div class="h-64"> This div has a height of 64 pixels.</div>Preview
Tailwind Percentage Height
Percent-based heights work well only when the parent has an explicit height. Otherwise, CSS treats percentages as “unknown” and collapses them. Tailwind gives you fractions like h-1/2 for common cases.
<div class="h-50..."> This div has a height of 50% of its parent container.</div>Preview
You will use this in grids, split layouts, or anywhere you want a child element to share vertical space with siblings.
Responsive Tailwind Height
Tailwind CSS allows you to control the height of elements responsively at different breakpoints. To use responsive Tailwind height classes, you can append the breakpoint prefix to the height classes. For example, md:h-48 sets the height to 48 pixels starting from the medium breakpoint and above.
<div class="h-64 md:h-48"> This div has a height of 64 pixels by default, and 48 pixels starting from the medium breakpoint.</div>Preview
This div has a height of 64 pixels by default, and 48 pixels starting from the medium breakpoint.
A common pattern is using a tall section on mobile (because scrolling is cheap) and reducing it on desktop where horizontal layout becomes more important.
Interaction State Use (hover/focus)
You can animate height changes if you want an element to expand when interacted with. Works well for cards, small menus, or “peek” components.
<div class="h-40 hover:h-64 transition-all duration-300 overflow-hidden bg-white shadow rounded"> <p class="p-4">Hover to expand height</p></div>Preview
Hover to expand height
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quia et nam odit expedita perspiciatis laborum error accusamus, voluptas nulla a at culpa blanditiis vero assumenda, voluptatum ex fugit excepturi amet!
Just be careful: animated height can cause layout shift, so don’t use it near important text or buttons unless the movement is intentional.
✏️ Arbitrary Value Usage
Sometimes the design has a very specific number, a Figma component height of 72px, a viewport percentage, or a clamp function for a fluid layout.
<div class="h-[72px]">Exact height</div><div class="h-[35vh]">35% of viewport height</div><div class="h-[clamp(200px,50vh,600px)]">Fluid height</div>Preview
Arbitrary values are great for one-off components, but if you're repeating the same height across the app, move it into the config so it doesn’t become magic numbers scattered everywhere.
Customization in tailwind.config.js
When your project settles into a real design system, you’ll want reusable height for headers, navbars, hero sections, etc.
// tailwind.config.jsmodule.exports = { theme: { extend: { height: { 'header': '4.5rem', 'hero': '80vh', 'half': '50%', }, }, },};<header class="h-header bg-gray-50 text-gray-700 flex justify-between items-center p-4 font-bold"> <a>Logo</a> <ul class="flex gap-4 m-2"> <li>Home</li> <li>Product</li> <li>Contact</li></ul></header><section class="h-hero bg-gray-900 text-white flex justify-between items-center p-5 space-x-4"><div class="text-center flex-col"><h2 class="text-xl font-bold m-3">Running your business with AI faster</h2><p class="text-center p-4">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><button class="text-center bg-white rounded-lg text-gray-800 p-3 cursor-pointer">Get Started</button></div></section>Preview
- Home
- Product
- Contact
Running your business with AI faster
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
This keeps your layout decisions consistent and avoids guessing later.
🧩 Real UI Component Examples
Practical cases where height matters more than you expect.
📦 Scrollable Chat Panel
<div class="h-96 overflow-y-auto bg-white shadow-inner rounded p-4"> <p class="mb-2">Chat message 1</p> <p class="mb-2">Chat message 2</p> <!-- ... --></div>Preview
Marian Anderson
Marian Anderson
Scrollable regions rely on a fixed height. Without it, overflow won’t work.
📱 Responsive Hero Banner
<section class="h-screen flex items-center justify-center bg-linear-to-r from-purple-600 to-indigo-600 text-white"> <h1 class="text-4xl font-bold">Full-Screen Hero</h1></section>Preview
Full-Screen Hero
One thing to remember: h-screen acts weird on some mobile browsers due to dynamic toolbars. Test it if your hero is above the fold.
Sticky Navbar
<header class="h-16 bg-white shadow-md fixed top-0 left-0 w-full z-50 flex justify-between items-center px-6"> <span class="font-semibold text-lg">App Logo</span> <ul class="flex justify-between items-center gap-4"> <li>Home</li> <li>Service</li> <li>Contact</li> </ul></header>Preview
- Home
- Service
- Contact
A fixed navbar needs a defined height so the content below can offset itself.
Image with Aspect Ratio
<div class="h-64 overflow-hidden rounded"> <img src="/image.jpg" alt="Preview" class="h-full w-full object-cover" /></div>Preview
Pairing h-* with object-cover is one of the cleanest ways to keep images predictable.
Tailwind Height class Table
| Class | Properties |
|---|---|
| h-0 | height: 0px; |
| h-0.5 | height: 0.125rem; |
| h-1 | height: 0.25rem; |
| h-1.5 | height: 0.375rem; |
| h-2 | height: 0.5rem; |
| h-2.5 | height: 0.625rem; |
| h-3 | height: 0.75rem; |
| h-3.5 | height: 0.875rem; |
| h-4 | height: 1rem; |
| h-5 | height: 1.25rem; |
| h-6 | height: 1.5rem; |
| h-7 | height: 1.75rem; |
| h-8 | height: 2rem; |
| h-9 | height: 2.25rem; |
| h-10 | height: 2.5rem; |
| h-11 | height: 2.75rem; |
| h-12 | height: 3rem; |
| h-14 | height: 3.5rem; |
| h-16 | height: 4rem; |
| h-20 | height: 5rem; |
| h-24 | height: 6rem; |
| h-28 | height: 7rem; |
| h-32 | height: 8rem; |
| h-36 | height: 9rem; |
| h-40 | height: 10rem; |
| h-44 | height: 11rem; |
| h-48 | height: 12rem; |
| h-52 | height: 13rem; |
| h-56 | height: 14rem; |
| h-60 | height: 15rem; |
| h-64 | height: 16rem; |
| h-72 | height: 18rem; |
| h-80 | height: 20rem; |
| h-96 | height: 24rem; |
| h-auto | height: auto; |
| h-1/2 | height: 50%; |
| h-1/3 | height: 33.333333%; |
| h-2/3 | height: 66.666667%; |
| h-1/4 | height: 25%; |
| h-2/4 | height: 50%; |
| h-3/4 | height: 75%; |
| h-1/5 | height: 20%; |
| h-2/5 | height: 40%; |
| h-3/5 | height: 60%; |
| h-4/5 | height: 80%; |
| h-1/6 | height: 16.666667%; |
| h-2/6 | height: 33.333333%; |
| h-3/6 | height: 50%; |
| h-4/6 | height: 66.666667%; |
| h-5/6 | height: 83.333333%; |
| h-full | height: 100%; |
| h-screen | height: 100vh; |
Why Height Matters in Web Design
Controlling an element’s height is essential for:
-
Visual balance: Tall vs. short elements influence layout symmetry
-
Usability: Scrollable areas or fixed sections
-
Responsiveness: Making sure elements adapt across screen sizes
Design integrity: Maintaining consistent sizing for headers, images, and cards
📚 Keep Exploring
Windframe Tailwind blocks
Windframe is an AI visual editor for rapidly building stunning web UIs & websites
Start building stunning web UIs & websites!

