Tailwind CSS Handbook v4.3

Sizing

Width, height, min/max constraints and the size-* shorthand — plus when to prefer intrinsic sizing over fixed dimensions.

Sizing utilities draw from the same spacing scale as padding and margin, plus fractions, viewport units and content-based keywords.

Width#

UtilityValue
w-4, w-64, w-96Spacing scale (0.25rem × n)
w-1/2, w-2/3, w-5/12Fractions of the parent
w-full100%
w-screen100vw
w-dvw / w-svw / w-lvwDynamic / small / large viewport width
w-min / w-max / w-fitIntrinsic sizing
w-autoDefault
w-px1px
w-[37ch]Arbitrary

v4.2 Logical equivalents: inline-* for inline size, block-* for block size, plus min-inline-*, max-inline-*, min-block-* and max-block-*.

Intrinsic sizing#

UtilityMeaning
w-minAs narrow as possible without overflow — wraps at every opportunity
w-maxAs wide as the content wants — never wraps
w-fitmin(max-content, available) — shrink-to-fit, capped by the parent

w-fit is the useful one: it sizes a block element to its content without making it inline.

Loading preview…

Height#

UtilityValue
h-4, h-64Spacing scale
h-full100% — only works if the parent has a resolved height
h-screen100vh
h-dvh100dvh — accounts for mobile browser chrome
h-svh / h-lvhSmall / large viewport height
h-min / h-max / h-fitIntrinsic

size-*#

Sets width and height together — ideal for avatars, icons and buttons.

HTML
<img class="size-10 rounded-full" src="…" alt="">
<svg class="size-5" …></svg>

size-10 replaces h-10 w-10. It accepts the same values: size-full, size-fit, size-1/2.

Min and max#

UtilityPurpose
min-w-0Allow a flex/grid item to shrink below its content
min-w-full, min-w-64Floors
max-w-*Ceilings — see the table below
min-h-screen, min-h-dvhFull-height pages
max-h-96, max-h-screenScroll containers

The max-w-* scale#

UtilityWidthUtilityWidth
max-w-xs20remmax-w-3xl48rem
max-w-sm24remmax-w-5xl64rem
max-w-md28remmax-w-7xl80rem
max-w-lg32remmax-w-full100%
max-w-xl36remmax-w-prose~65ch

These come from the --container-* theme namespace, shared with container queries.

Aspect ratio#

UtilityRatio
aspect-square1 / 1
aspect-video16 / 9
aspect-3/2, aspect-4/5Arbitrary fractions
aspect-autoContent-driven
Loading preview…

Combine with object-cover so images fill the box without distortion:

HTML
<img class="aspect-video w-full rounded-lg object-cover" src="…" alt="">

Object fit and position#

UtilityBehaviour
object-coverFill the box, cropping overflow
object-containFit entirely inside, letterboxing
object-fillStretch — distorts
object-noneNative size
object-center, object-top, object-left-bottomFocal point

Common patterns#

Responsive image card#

HTML
<figure class="overflow-hidden rounded-xl border border-gray-200">
  <img class="aspect-video w-full object-cover" src="…" alt="">
  <figcaption class="p-4 text-sm text-gray-600">Caption</figcaption>
</figure>

Full-height app shell#

HTML
<div class="flex min-h-dvh flex-col">
  <header class="shrink-0">…</header>
  <main class="flex-1 overflow-y-auto">…</main>
</div>

min-h-dvh rather than h-dvh lets the page grow if the content is taller.

Fixed sidebar, fluid content#

HTML
<div class="flex gap-6">
  <aside class="w-64 shrink-0">…</aside>
  <main class="min-w-0 flex-1">…</main>
</div>

Both shrink-0 and min-w-0 are load-bearing here.

Readable prose column#

HTML
<article class="mx-auto max-w-prose px-6">…</article>

Square avatar grid#

HTML
<div class="grid grid-cols-4 gap-2">
  <img class="aspect-square w-full rounded-lg object-cover" src="…" alt="">
</div>

Common mistakes#

  • h-full with no parent height. Percentage heights need a resolved parent height. Use h-dvh, min-h-dvh, or a flex/grid parent.
  • w-screen inside a padded container. 100vw includes the scrollbar and ignores the parent, causing horizontal overflow. w-full is almost always what you meant.
  • h-screen on mobile. Use h-dvh.
  • Forgetting object-cover with aspect-*. The image distorts to fill the box.
  • Fixed heights on text containers. Text length varies; use min-h-* and let it grow.
  • Missing min-w-0 on a flex child that should truncate. The most common truncation bug.