Open In App

How to set the Width and Height in Tailwind CSS ?

Setting the width and height in Tailwind CSS involves using utility classes like w-[size] and h-[size]. These classes allow you to easily define the width and height of elements in your project.

Setting Width

To define the width of an element, employ the w-[size] classes, replacing [size] them To establish an element's heightwith options like 1/2, full, screen, or numerical values.

<div class="w-1/2">
This element occupies half the width of its parent.
</div>

Setting Height

To establish an element’s height, use the h-[size] classes with size identifiers such as 1/4, full, screen, or numerical values.

<div class="h-64">
This element has a fixed height of 16rem.
</div>

Key Features

Article Tags :