Typography for Engineers
This article belongs to the UI/UX for Developers course, which is currently being revisited with updated architectural patterns and content. Content may be refined shortly.
Over 90% of information in modern web and mobile software is communicated through written text.
You can design an elegant backend architecture, but if your typography has poor contrast, suffocating line heights, or chaotic sizing, users will experience subtle eye fatigue and cognitive friction. Typography is not merely picking a stylish font—it is the engineering of text for rapid scanning, legibility, and visual hierarchy.
1. Interactive Type Scale & Tabular Explorer
A modular type scale multiplies a base font size (typically 16px) by a fixed mathematical ratio (such as 1.25 — a Major Third scale). This creates natural, harmonious hierarchy between headers and body copy.
Step through the interactive visualizer below to see how a modular scale creates natural hierarchy, and witness how tabular numbers solve column jitter in data tables:
Modular Type Scale & Typography
Modular Type Scale (Major Third 1.25x)/* Tailwind Font Size Scale */ text-xs: 12px (0.75rem) - Metadata & Badges text-sm: 14px (0.875rem) - Secondary Copy text-base: 16px (1.0rem) - Body Default text-lg: 18px (1.125rem) - Subheaders text-xl: 20px (1.25rem) - Card Titles text-2xl: 24px (1.5rem) - Section Headers text-3xl: 30px (1.875rem) - Page Headers text-4xl: 36px (2.25rem) - Hero Headlines
A modular type scale multiplies a base size (e.g. 16px) by a harmonious ratio (such as 1.25). This ensures headings and body text maintain consistent visual proportions.
2. Typeface Classifications for Software
Digital applications rely on three primary typeface categories:
| Classification | Visual Characteristics | Recommended Engineering Use |
|---|---|---|
| Sans-Serif | Clean, geometric, neutral (Inter, SF Pro, Roboto) | Default UI screens, buttons, navigation, dashboards |
| Monospace | Every character has identical width (JetBrains Mono, Fira) | Code blocks, timestamps, financial tables, counters |
| Serif | Classical decorative brackets (Merriweather, Georgia) | Editorial long-form reading, documentation essays |
Developer Rule: Stick to one solid Sans-Serif font (or modern system font stacks) for your UI, and one Monospace font for technical data. Avoid mixing more than two typefaces in a single product.
3. The Inverse Line-Height Rule
Line height (leading) governs the vertical distance between lines of text.
A frequent developer mistake is applying a uniform line-height: 1.5 everywhere.
The Golden Formula:
- Headings need TIGHT line height ($1.1 - 1.25$): Because headline fonts are large, a $1.5$ line height leaves enormous, awkward gaps between wrapped lines.
- Body text needs RELAXED line height ($1.5 - 1.6$): Small text squeezed together causes eye fatigue as the reader’s eye jumps between lines.
/* Headline: Tight line height */
h1 {
font-size: 2.25rem; /* 36px */
line-height: 1.15; /* ~41px (Tailwind: leading-tight) */
letter-spacing: -0.02em; /* tracking-tight */
}
/* Body: Comfortable reading line height */
p {
font-size: 1rem; /* 16px */
line-height: 1.6; /* 25.6px (Tailwind: leading-relaxed) */
}
4. Line Length: The 45–75 Character Measure
If a line of text spans the full width of an ultrawide desktop monitor (e.g. 1920px), reading becomes exhausting because the user’s eye struggles to find the start of the next line.
- Optimal Reading Width: 45 to 75 characters per line (including spaces).
- The CSS Solution: Use the
chunit, which corresponds to the width of the0character:
.article-body {
max-width: 65ch; /* Perfectly constrains line length for comfortable reading */
}
In Tailwind CSS:
<article class="max-w-prose leading-relaxed">
<p>Long form content constrained to optimal reading width...</p>
</article>
5. Tabular Numbers: The Secret for Data Alignment
By default, fonts use proportional numbers, meaning the digit 1 is much narrower than the digit 8. In financial tables, timers, or live counters, this causes jagged vertical alignment and layout jitter:
Proportional Numbers (Columns Jitter)
Tabular Numbers (Pixel Aligned)
/* Enable fixed-width numerals for all digits 0-9 */
.financial-table td {
font-variant-numeric: tabular-nums;
}
In Tailwind CSS:
<span class="tabular-nums font-mono">1,429.50 USD</span>
6. Letter Spacing (Tracking) Guidelines
- Large Bold Headings: Apply subtle negative tracking (
letter-spacing: -0.02em/tracking-tight). Large glyphs naturally feel too spaced out. - All-Caps Badges & Labels: Apply generous positive tracking (
letter-spacing: 0.05emto0.1em/tracking-wider). All-caps text is naturally dense and needs extra breathing room to remain legible.