Min-Width, Max-Width, Min-Height, and Max-Height in Tailwind CSS

Updated: May 17, 2022 By: Pennywise Post a comment

In Tailwind CSS, you can set the minimum width of an element by using the following utilities:

  • min-w-0
  • min-w-full
  • min-w-min
  • min-w-max
  • min-w-fit

To set the maximum width for an element, use max-w-{value}. Value can be 0, xs, sm, md, lg, xl, etc. You can see the full list of available values in the official docs.

To set the minimum height for an element, you can use the following utilities:

  • min-h-0
  • min-h-full
  • min-h-screen
  • min-h-min
  • min-h-max
  • min-h-fit

To set the maximum height for an element, use max-h-{value}. Value can be 0, 0.5, 1, 1.5, etc. You can see the full list of available numbers in the official docs.

Example

Screen record:

The code:

<body>
    <div class="px-3 py-20 w-full bg-indigo-500">
        <div class="mx-auto max-w-xs h-36 sm:max-w-md md:max-w-xl bg-amber-500"></div>
    </div>
</body>

Further reading:

You can also check out our CSS category page for the latest tutorials and examples.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Related Articles