Tailwind CSS Cheatsheet

Layout and Display

Use this Tailwind CSS reference while you build software engineering projects, review code for technical interview prep, or polish examples for a software engineer resume.

Display

Control the display CSS property.

ClassCSS
blockdisplay: block
inline-blockdisplay: inline-block
inlinedisplay: inline
flexdisplay: flex
inline-flexdisplay: inline-flex
griddisplay: grid
inline-griddisplay: inline-grid
tabledisplay: table
table-celldisplay: table-cell
table-rowdisplay: table-row
contentsdisplay: contents
list-itemdisplay: list-item
hiddendisplay: none
flow-rootdisplay: flow-root
<div class="hidden md:block">Visible on md+ only</div>
<span class="inline-block w-4 h-4 bg-blue-500 rounded-full"></span>

Container

Centers content and applies max-width tied to the current breakpoint.

<div class="container mx-auto px-4">
  <!-- content -->
</div>
BreakpointMax-width
sm640px
md768px
lg1024px
xl1280px
2xl1536px

container sets max-width to the current breakpoint's value but does not center by default in v3 — add mx-auto. In v4 configure it in your CSS with @utility.

Positioning

Position Type

ClassCSS
staticposition: static
relativeposition: relative
absoluteposition: absolute
fixedposition: fixed
stickyposition: sticky

Inset / TRBL

Controls top, right, bottom, left using the spacing scale.

ClassCSS
inset-0top: 0; right: 0; bottom: 0; left: 0
inset-x-0left: 0; right: 0
inset-y-0top: 0; bottom: 0
top-0top: 0
top-4top: 1rem
top-1/2top: 50%
top-fulltop: 100%
top-autotop: auto
-top-4top: -1rem
top-[72px]top: 72px

Same scale applies to right-*, bottom-*, left-*, and inset-*.

<!-- Centered overlay -->
<div class="relative">
  <div class="absolute inset-0 bg-black/50"></div>
  <div class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2">
    Centered
  </div>
</div>

<!-- Sticky header -->
<header class="sticky top-0 z-50 bg-white border-b">...</header>

Z-Index

ClassCSS
z-0z-index: 0
z-10z-index: 10
z-20z-index: 20
z-30z-index: 30
z-40z-index: 40
z-50z-index: 50
z-autoz-index: auto
-z-10z-index: -10
z-[100]z-index: 100

Float and Clear

ClassCSS
float-leftfloat: left
float-rightfloat: right
float-nonefloat: none
float-startfloat: inline-start
float-endfloat: inline-end
clear-leftclear: left
clear-rightclear: right
clear-bothclear: both
clear-noneclear: none

Object Fit and Position

For <img>, <video>, and replaced elements.

ClassCSS
object-containobject-fit: contain
object-coverobject-fit: cover
object-fillobject-fit: fill
object-noneobject-fit: none
object-scale-downobject-fit: scale-down
object-centerobject-position: center
object-topobject-position: top
object-bottomobject-position: bottom
object-leftobject-position: left
object-rightobject-position: right
object-left-topobject-position: left top
object-[50%_25%]object-position: 50% 25%
<img class="w-full h-48 object-cover object-center" src="photo.jpg" alt="">

Overflow

ClassCSS
overflow-autooverflow: auto
overflow-hiddenoverflow: hidden
overflow-clipoverflow: clip
overflow-visibleoverflow: visible
overflow-scrolloverflow: scroll
overflow-x-autooverflow-x: auto
overflow-y-autooverflow-y: auto
overflow-x-hiddenoverflow-x: hidden
overflow-y-scrolloverflow-y: scroll
<!-- Truncate text to single line -->
<p class="overflow-hidden text-ellipsis whitespace-nowrap">Long text...</p>

<!-- Scrollable container -->
<div class="overflow-y-auto max-h-64">...</div>

Visibility

ClassCSS
visiblevisibility: visible
invisiblevisibility: hidden
collapsevisibility: collapse

invisible hides the element but preserves its space in layout. hidden (display: none) removes it from layout entirely.

Overscroll Behavior

ClassCSS
overscroll-autooverscroll-behavior: auto
overscroll-containoverscroll-behavior: contain
overscroll-noneoverscroll-behavior: none
overscroll-x-containoverscroll-behavior-x: contain
overscroll-y-noneoverscroll-behavior-y: none
<!-- Prevent scroll chaining on a modal -->
<div class="overflow-y-auto overscroll-contain h-screen">...</div>

Isolation

ClassCSS
isolateisolation: isolate
isolation-autoisolation: auto

Creates a new stacking context without changing z-index. Useful to contain mix-blend-mode effects.

Box Sizing

ClassCSS
box-borderbox-sizing: border-box
box-contentbox-sizing: content-box

Preflight sets box-border on all elements by default.

Aspect Ratio

ClassCSS
aspect-autoaspect-ratio: auto
aspect-squareaspect-ratio: 1 / 1
aspect-videoaspect-ratio: 16 / 9
aspect-[4/3]aspect-ratio: 4 / 3
<div class="aspect-video w-full bg-black">
  <iframe class="w-full h-full" src="..."></iframe>
</div>

Columns (Multi-column Layout)

ClassCSS
columns-1columns-12columns: 1columns: 12
columns-autocolumns: auto
columns-3xscolumns: 16rem
columns-xscolumns: 20rem
columns-smcolumns: 24rem
columns-mdcolumns: 28rem
columns-lgcolumns: 32rem
columns-xlcolumns: 36rem
<div class="columns-3 gap-4">
  <p>Column item...</p>
  <p>Column item...</p>
  <p>Column item...</p>
</div>

Column Break

ClassCSS
break-before-autobreak-before: auto
break-before-pagebreak-before: page
break-before-columnbreak-before: column
break-before-avoidbreak-before: avoid
break-after-columnbreak-after: column
break-inside-avoidbreak-inside: avoid
break-inside-avoid-columnbreak-inside: avoid-column

Break (Word and Line)

ClassCSS
break-normaloverflow-wrap: normal; word-break: normal
break-wordsoverflow-wrap: break-word
break-allword-break: break-all
break-keepword-break: keep-all

Line Clamp

Clamp multi-line text to N lines with an ellipsis:

<p class="line-clamp-3">
  This long paragraph will be clamped to three lines...
</p>

<p class="line-clamp-none">No clamping</p>
ClassLines
line-clamp-11
line-clamp-22
line-clamp-33
line-clamp-44
line-clamp-55
line-clamp-66
line-clamp-noneno clamp