Tailwind Height

The height utility class in Tailwind CSS allows you to easily control the height of elements. It provides a set of classes that enable you to set the height of elements to specific values, percentages, or use predefined height utilities for common use cases.

Setting Tailwind Height

To set the Tailwind height of an element, you can use the h-{size} class, where {size} can be one of the following options:

  • 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.

Here's an example of how to use the height utility classes:

html
<div class="h-64">
This div has a height of 64 pixels.
</div>

Preview

This div has a height of 64 pixels.

Percentage-based Tailwind Height

Tailwind CSS also provides utility classes for setting height as a percentage of the parent container's height. You can use the h-{percentage} class to achieve this. Here's an example:

html
<div class="h-50...">
This div has a height of 50% of its parent container.
</div>

Preview

This div has a height of 50% of its parent container.

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. Here's an example:

html
<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>

In the above example, the h-64 class is applied by default, setting the height to 64 pixels. However, starting from the medium breakpoint and above, the md:h-48 class is applied, changing the height to 48 pixels.

Tailwind Height class Table

ClassProperties
h-0height: 0px;
h-0.5height: 0.125rem;
h-1height: 0.25rem;
h-1.5height: 0.375rem;
h-2height: 0.5rem;
h-2.5height: 0.625rem;
h-3height: 0.75rem;
h-3.5height: 0.875rem;
h-4height: 1rem;
h-5height: 1.25rem;
h-6height: 1.5rem;
h-7height: 1.75rem;
h-8height: 2rem;
h-9height: 2.25rem;
h-10height: 2.5rem;
h-11height: 2.75rem;
h-12height: 3rem;
h-14height: 3.5rem;
h-16height: 4rem;
h-20height: 5rem;
h-24height: 6rem;
h-28height: 7rem;
h-32height: 8rem;
h-36height: 9rem;
h-40height: 10rem;
h-44height: 11rem;
h-48height: 12rem;
h-52height: 13rem;
h-56height: 14rem;
h-60height: 15rem;
h-64height: 16rem;
h-72height: 18rem;
h-80height: 20rem;
h-96height: 24rem;
h-autoheight: auto;
h-pxheight: 1px;
h-1/2height: 50%;
h-1/3height: 33.333333%;
h-2/3height: 66.666667%;
h-1/4height: 25%;
h-2/4height: 50%;
h-3/4height: 75%;
h-1/5height: 20%;
h-2/5height: 40%;
h-3/5height: 60%;
h-4/5height: 80%;
h-1/6height: 16.666667%;
h-2/6height: 33.333333%;
h-3/6height: 50%;
h-4/6height: 66.666667%;
h-5/6height: 83.333333%;
h-fullheight: 100%;
h-screenheight: 100vh;

Windframe Tailwind blocks

blog

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.

ad-banner