Tailwind css tutorial Hindi #7 Width | Minimum Width | Maximum width in Tailwind version 4
Width, Min-Width and Max-Width
Width, min-width and max-width control how wide a box can be: actual width, minimum limit, and maximum limit. In Tailwind, all three are easy with simple classes like w-…, min-w-…, max-w-….
•Apply width, min-width, max-width.
Basic width, min-width, max-width
Width: w-…
Example: w-40 (fix width), w-full (take 100% of parent), w-auto (fit content or layout).
Min-width: min-w-…
Example: min-w-40, min-w-full (at least full width of parent).
Max-width: max-w-…
Example: max-w-xs, max-w-md, max-w-full (never grow more than this limit).
•Width in percentage.
Use fraction classes or w-full:
w-1/2 → 50% of parent.
w-1/3, w-2/3, w-1/4, w-3/4 etc. → percentage widths.
w-full → 100% width.
These are very common in responsive layouts.
•Provide specific width.
If scale classes are not exact, use arbitrary values:
Exact width: w-[300px], w-[600px] etc.
Exact min-width: min-w-[200px].
Exact max-width: max-w-[500px].
This is helpful for things like cards, modals, or sidebars.
• Width with hover.
Use hover variants:
<div class="w-40 hover:w-60 transition-all duration-300">
Hover me
</div>
•Interview Question
What if we put width greater than max-width
Use of auto width
Height, Min-Height and Max-Height
Height, min-height and max-height control how tall a box can be: actual height, minimum limit and maximum limit
•Apply Height, min-Height, max-Height.
- Basic height, min-height, max-height
- Tailwind pattern is simple:
- Height: h-…
- Examples: h-10, h-40, h-full, h-auto.
- Min-height: min-h-…
- Examples: min-h-0, min-h-full, min-h-screen.
- Max-height: max-h-…
- Examples: max-h-0, max-h-full, max-h-[200px].
- Min-height = cannot be smaller than this.
- Max-height = cannot be bigger than this.
• Full Screen Height.
h-screen → height = 100% of viewport height (full screen).
For “minimum full screen” section: min-h-screen (at least full screen, can grow if content is more).
Example: <section class="min-h-screen bg-blue-500">
...
</section>
• Height in percentage.
Use:
- h-full → 100% of parent height.
- Parent must have some height set (like min-h-screen, fixed h-96, etc.), otherwise percentage has no effect.
- For custom percentage once:
- h-[50%], h-[75%] etc.
• Provide specific Height.
- When built-in sizes are not exact:
- h-[200px], h-[500px] etc. → exact pixel height.
- min-h-[300px], max-h-[400px] → exact min or max height.
- Very useful for cards, modals, sidebars.
•Height with hover.
- Just like width, use hover variant:
<div class="h-20 hover:h-40 transition-all duration-300">
Hover me
</div>
- Normal: h-20, on hover: hover:h-40, and transition-all duration-300 makes it smooth.
•Interview Question
What is View Port
h-screen vs h-full