×

Tailwind CSS Height

This class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS height property. This class is used to specify an element's height. Padding, margin, and element borders are not included in the height class.

CSS Height Classes

The classes based on height are as follows:

  • h-0: The height is set to zero using this class.
  • h-auto: This class automatically adjusts the height based on the content.
  • h-px: This class is used to specify the height in one-pixel increments.
  • h-1/2: This class reduces the window's height to half its original size.
  • h-1/3: This class reduces the window's height to one-third of its original size.
  • h-1/4: This class reduces the window's height to one-fourth of its original size.
  • h-1/5: This class reduces the window's height to one-fifth of its original size.
  • h-1/6: This class reduces the window's height to one-sixth of its original size.
  • h-full: As long as the parent has a defined height, this class sets an element's height to 100% of its parent.
  • h-screen: This class is used to make an element fill the viewport's entire height.

Note: You can adjust the number or set the percentage value by using the valid "rem" values.

h-0

This class is used to specify the height of any element. You can replace the number with a correct number of rem units to fix the element's height.

Syntax is:

<element class="h-0">...</element>

Example

Example is as follows:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center mx-4 space-y-2">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>Height Class - Tailwind CSS</b>
    <div class="flex flex-wrap-reverse p-4 mx-12
                space-x-4 h-64 bg-red-200">
        <div class="h-8 w-12 bg-red-400
                    rounded-lg">h-8</div>
        <div class="h-12 w-12 bg-red-400
                    rounded-lg">h-12</div>
        <div class="h-16 w-12 bg-red-400
                    rounded-lg">h-16</div>
        <div class="h-20 w-12 bg-red-400
                    rounded-lg">h-20</div>
        <div class="h-24 w-12 bg-red-400
                    rounded-lg">h-24</div>
        <div class="h-32 w-12 bg-red-400
                    rounded-lg">h-32</div>
        <div class="h-40 w-12 bg-red-400
                    rounded-lg">h-40</div>
        <div class="h-48 w-12 bg-red-400
                    rounded-lg">h-48</div>
        <div class="h-52 w-12 bg-red-400
                    rounded-lg">h-52</div>
    </div>
</body>
</html>

Output:

Tailwind CSS Height

h-auto

This class allows the browser to determine the element's height.

Syntax:

<element class="h-auto">...</element>

Example

Example is as follows:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center mx-4 space-y-2">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Height Class - Tailwind CSS </b>
    <div class="mx-48 bg-red-200 p-8">
        <div class="h-auto bg-red-400
                    rounded-lg">h-auto</div>
    </div>
</body>
</html>

Output:

Tailwind CSS Height

h-screen

This class is used to make an element fill the viewport's entire height.

Syntax is:

<element class="h-screen">...</element>

Example

Example is as follows:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center mx-4 space-y-2">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Height Class - Tailwind CSS </b>
    <div class="mx-48 bg-red-200 p-8">
        <div class="h-screen bg-red-400
                    rounded-lg">h-screen</div>
    </div>
</body>
</html>

Output:

Tailwind CSS Height

h-full

As long as the parent has a defined height, this class sets an element's height to 100% of its parent.

Syntax:

<element class="h-full">...</element>

Example

Example is as follows:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center mx-4 space-y-2">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Height Class - Tailwind CSS </b>
    <div class="mx-48 h-48 bg-red-200 p-8">
        <div class="h-full bg-red-400
                    rounded-lg">h-full</div>
    </div>
</body>
</html>

Output:

Tailwind CSS Height

Related Topics

Tailwind CSS Height

This class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS height property. This class is used...

4 minutes read.

Tailwind CSS Margin

The margin class accepts a large number of values, and all of the properties are covered in the same way they are in the class form. It's a replacement for...

6 minutes read.

Tailwind CSS Grid Template Rows

In tailwind CSS, this class accepts multiple values and all properties are covered in class form. It's the CSS grid-template-row property's replacement. It is used to set the number of...

2 minutes read.

Tailwind CSS Installation

Here, we will discuss the installation method of Tailwind CSS using two strategies discussed as follows: Strategy 1: Install Tailwind through npm Step 1: npm init - y Step 2: npm install tailwindcss Step...

2 minutes read.

Tailwind CSS Justify Content

In tailwind CSS, this class accepts two values. It's a replacement for CSS's justify-content attribute. This class is used to describe the flexible box container's alignment. Along the main axis...

4 minutes read.

Tailwind CSS Flex Grow

CSS flexbox is an important element for frontend development; there are two flex-grow options in Tailwind CSS, and all attributes are covered in class form. It is an alternative to...

3 minutes read.

Tailwind CSS Place Self

The tailwind CSS Place self class accepts a wide range of values. It's a replacement for the CSS Place Items property. This class is used to manage how a single...

4 minutes read.

Tailwind CSS Clear

This class acknowledges more than one worth in tailwind CSS. Every one of the properties is canvassed as in class form. It is an option in contrast to the CSS...

5 minutes read.

Tailwind CSS Max-Height

This class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Max-Height attribute. It is used to...

3 minutes read.

Tailwind CSS Align Self

This class accepts a wide range of values. It's a replacement for the CSS Align Self attribute. This class is used to control how a flex or grid item is...

4 minutes read.

Tailwind CSS Order

One of the best features of Tailwind CSS is the Order class, which allows us to order flex and grid objects according to our needs. There are several different order...

2 minutes read.

Tailwind CSS Min-Width

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS min-width property. This...

1 minute read.

Tailwind CSS Flex

CSS flexbox is an important component for frontend development. There are four flex options in Tailwind CSS, and all of the attributes are covered in class form. It's a front-end...

6 minutes read.

Tailwind CSS Gap

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It's a replacement for the CSS gap attribute. This class is used...

4 minutes read.

Tailwind CSS Justify Items

It is a replacement for the CSS justify-items attribute. This class is used to regulate the alignment of grid objects along their inline axis. Justify Item It is classified as: justify-items-auto justify-items-start justify-items-end justify-items-center justify-items-stretch justify-items-auto The justify-items-auto class...

4 minutes read.

Tailwind CSS Width

The tailwind CSS width class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Width Property. This...

3 minutes read.

Tailwind CSS Align Content

In Tailwind CSS, this class accepts a wide range of values. It's a replacement for the CSS Align Content feature. This class is used to modify the flex-wrap property's behavior....

5 minutes read.

Tailwind CSS Flex Wrap

CSS flexbox is an important component for frontend development. It is a front-end development alternative to the CSS flex-wrap Property. Note: You must include the flex class in your element before...

4 minutes read.

Tailwind CSS Space Between

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Space Between property....

4 minutes read.

Tailwind CSS tutorial

Tailwind CSS can be utilized to make sites in the quickest and the least demanding way. Tailwind CSS is the most famous utility-first CSS structure on the planet for quickly...

4 minutes read.