Skip to main content

Typography Cheatsheet

Font Shorthand

/* font: style variant weight size/line-height family */
font: italic small-caps 700 1.5rem/1.6 'Inter', sans-serif;

/* REQUIRED: size AND family */
/* OPTIONAL: style variant weight (in that order, before size) */
/* line-height: after size, separated by / */

font-family Stack Templates

/* Modern system UI */
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

/* Geometric sans (Inter-style) */
font-family: 'Inter', 'DM Sans', 'Manrope', system-ui, sans-serif;

/* Classic serif */
font-family: 'Playfair Display', 'Lora', 'Georgia', serif;

/* Monospace / code */
font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

/* Apple-first */
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;

font-weight Reference

ValueNameVariable Font
100Thin✅ Any value 1–1000
200Extra Light
300Light
400Regular (normal)
500Medium
600SemiBold
700Bold
800ExtraBold
900Black

font-size Units Guide

UnitRelative ToUse Case
pxScreen pixelsFixed — avoid for body/heading
remRoot (html) font-sizeUse for all text ✅
emParent's font-sizeUse for spacing relative to text
%Parent's font-sizeAvoid — same as em but confusing
vwViewport widthFluid text (combine with clamp)
clamp(min, ideal, max)DynamicBest for headings ✅

Base font size: don't set px on html/body — use % or rem from default 16px:

html { font-size: 100%; } /* 16px — browser respects user preference */

Fluid Type Scale (Copy-Paste)

:root {
--text-xs: clamp(0.75rem, 0.6rem + 0.3vw, 0.875rem);
--text-sm: clamp(0.875rem, 0.75rem + 0.4vw, 1rem);
--text-base: clamp(1rem, 0.85rem + 0.5vw, 1.125rem);
--text-lg: clamp(1.125rem, 0.9rem + 0.75vw, 1.375rem);
--text-xl: clamp(1.25rem, 1rem + 1vw, 1.75rem);
--text-2xl: clamp(1.5rem, 1.1rem + 1.5vw, 2.25rem);
--text-3xl: clamp(1.875rem, 1.2rem + 2.5vw, 3rem);
--text-4xl: clamp(2.25rem, 1.5rem + 3vw, 4rem);
--text-hero: clamp(3rem, 2rem + 5vw, 6rem);
}

line-height Guide

ValueEffectUse
1Same as font-sizeHeadings (tight)
1.220% extraLarge display headings
1.550% extraBody text minimum
1.770% extraLong-form articles
normal~1.2 (browser decides)Avoid — unpredictable
1.5remFixed — doesn't scaleAvoid in most cases

Text Properties

/* Alignment */
text-align: left | right | center | justify | start | end;

/* Transform */
text-transform: uppercase | lowercase | capitalize | none;

/* Decoration */
text-decoration: none | underline | line-through | overline;
text-decoration-color: var(--color-primary);
text-decoration-thickness: 2px;
text-underline-offset: 3px; /* Space between text and underline (great for links) */

/* Spacing */
letter-spacing: 0.05em; /* Tracking — use em so it scales with font-size */
word-spacing: 0.1em;

/* Wrapping and overflow */
white-space: normal | nowrap | pre | pre-wrap | pre-line;
word-break: normal | break-all | keep-all | break-word;
overflow-wrap: normal | break-word | anywhere;
hyphens: none | manual | auto; /* auto requires lang attribute on html */

/* Indentation */
text-indent: 2em;

/* Columns text */
text-align: justify;
hyphens: auto;

<!-- Inter (variable weight 100-900) -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" rel="stylesheet">

<!-- Playfair Display (variable weight + italic) -->
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap" rel="stylesheet">

<!-- DM Sans -->
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,300..700;1,300..700&display=swap" rel="stylesheet">

<!-- Combo: body + display -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap" rel="stylesheet">
/* Always add this — browsers default inputs to system font */
input, textarea, select, button { font: inherit; }

@font-face Template

@font-face {
font-family: 'MyFont';
src: url('/fonts/myfont.woff2') format('woff2');
font-weight: 100 900; /* Variable: range */
font-style: normal;
font-display: swap; /* Show fallback immediately, swap when loaded */
}

text-overflow Patterns

/* Single line ellipsis */
.truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

/* Multi-line clamp to N lines */
.c-clamp-3 {
display: -webkit-box;
-webkit-line-clamp: 3; /* Change number */
-webkit-box-orient: vertical;
overflow: hidden;
}