Typography for AI Coders | SheCodes
Beginner 10 min read

Typography Guide for AI Coders

Fonts, sizes, weights, and spacing: everything you need to know about text on the web. Use our Font Picker to browse and pair Google Fonts instantly.

In this chapter

  • How to pick fonts that look professional
  • What font sizes, weights, and line heights to use
  • How to pair two fonts without it looking messy
  • How to ask AI to swap fonts on your whole site

Font Size Scale

Use consistent sizes from a scale. Here's the Tailwind CSS default type scale.

Live example
text-xs12pxExtra small: captions, labels, fine print
text-sm14pxSmall: secondary text, descriptions, metadata
text-base16pxBase: body text, paragraphs (browser default)
text-lg18pxLarge: emphasized body text, subtitles
text-xl20pxExtra large: section subtitles, card headings
text-2xl24px2XL: section headings
text-3xl30px3XL: page headings
text-4xl36px4XL: hero headings
text-5xl48px5XL: large hero headings

Font Weights

Live example

Aa Bb Cc

font-light (300)

Subtle, delicate

Aa Bb Cc

font-normal (400)

Body text default

Aa Bb Cc

font-medium (500)

Slightly emphasized

Aa Bb Cc

font-semibold (600)

Subheadings, labels

Aa Bb Cc

font-bold (700)

Headings, emphasis

Aa Bb Cc

font-extrabold (800)

Hero headlines

Line Height & Letter Spacing

Live example

Line Height (leading)

Space between lines of text. Tighter for headings, looser for body text. See our spacing guide for more on vertical rhythm.

leading-tight1.25Headings
leading-snug1.375Subheadings
leading-normal1.5Body text (default)
leading-relaxed1.625Easy reading
leading-loose2Spacious text

Letter Spacing (tracking)

Space between individual characters. Wider for uppercase labels.

tracking-tighter-0.05emLarge headings
tracking-tight-0.025emHeadings
tracking-normal0emDefault
tracking-wide0.025emBody text
tracking-wider0.05emUppercase labels
tracking-widest0.1emALL CAPS text
Live example

Inter

Body text would look like this in Inter.

Inter + Inter

Clean, modern, versatile. The default for most web apps.

Playfair Display

Body text would look like this in Source Sans.

Playfair Display + Source Sans

Elegant serif + clean sans-serif. Great for blogs and magazines.

Space Grotesk

Body text would look like this in Inter.

Space Grotesk + Inter

Geometric, techy vibe. Perfect for SaaS and tech products.

DM Sans

Body text would look like this in DM Sans.

DM Sans + DM Sans

Friendly, rounded. Great for consumer apps.

Inter
Roboto
Open Sans
Poppins
Montserrat
Lato
DM Sans
Space Grotesk
Plus Jakarta Sans
Nunito
Raleway
Work Sans
Outfit
Manrope
Sora
Geist

Typography Rules of Thumb

Max line width: 65-75 characters Longer lines are harder to read. Use max-w-prose or max-w-2xl.
Use 2-3 font sizes max per section Too many sizes create visual chaos. Stick to heading + body + caption.
Body text: 16px minimum Anything smaller is hard to read, especially on mobile.
Headings: bold or extrabold Creates clear visual hierarchy. Body text should be normal weight.
Tighter tracking for large text Large headings look better with tracking-tight or tracking-tighter.
1 font family is usually enough One well-chosen font with different weights looks professional.

Text Decoration & Transform

These utilities change how text looks without changing the font itself. Great for emphasis, labels, and styling links.

Live example

Click here to learn more

underline

Best for: Links and clickable text

$49.99 now $29.99

line-through

Best for: Old prices, removed items

new feature

uppercase

Best for: Labels, badges, buttons

HELLO WORLD

lowercase

Best for: Normalizing user input

welcome to the app

capitalize

Best for: Titles, names, headings

Remove default link style

no-underline

Best for: Styled links and buttons

Text Truncation & Clamping

When text is too long for a card or list item, you can cut it off with an ellipsis (...) instead of letting it overflow. This keeps your layout clean.

Live example

Single-Line Truncation

Cuts text off at one line with "..." at the end. Perfect for titles and names.

This is a really long product title that would normally wrap to the next line and break the layout of your card component

truncate

Multi-Line Clamping

Shows 2-3 lines, then cuts off. Great for descriptions and previews.

This is a longer description that spans multiple lines. It keeps going and going with more detail about the product or article. Eventually it gets cut off after two lines with an ellipsis to keep your card looking tidy and consistent.

line-clamp-2 or line-clamp-3

Responsive Typography

Text should be smaller on phones and bigger on desktops. Tailwind makes this easy with responsive prefixes: just add the screen size before any text class.

Live example

Hero heading example:

Build Something Amazing

text-2xl sm:text-3xl md:text-4xl lg:text-5xl

Section heading example:

Getting Started with Your Project

text-lg sm:text-xl md:text-2xl

How the prefixes work:

(none)

All screens

< 640px

sm:

Small+

640px+

md:

Medium+

768px+

lg:

Large+

1024px+

Web Font Loading

Fonts need to be downloaded before they can be displayed. Here's what you need to know to keep your site fast and looking great. Use our Font Picker to browse pairings.

Google Fonts The most popular way to add fonts to your website. Free, easy to use, and works everywhere. Just tell your AI tool which Google Font you want and it will set it up for you.
Variable Fonts A single font file that contains all weights (light, regular, bold, etc.). Faster to load than downloading separate files for each weight. Most modern Google Fonts are variable.
Font Display: Swap A setting that shows a fallback font immediately while your custom font loads. Without it, visitors might see invisible text for a second or two. Always use this. Your AI tool should add it by default.
Performance Impact Every font you add makes your site a little slower to load. Each font weight (regular, bold, italic) is a separate download. Stick to 1-2 font families with 2-3 weights each for the best balance of style and speed.
SET UP WEB FONTS

“Add [font name] from Google Fonts to my project. Use the variable font version if available. Set font-display to swap for fast loading. Only load the weights I actually need: 400 for body text and 700 for headings. Set it as the default font for the whole site.”

Common Typography Mistakes

Watch out for these common issues that make text harder to read and sites look unprofessional.

Too Many Fonts Stick to 1-2 font families. Use different weights (bold, regular, light) for variety instead of adding more fonts.
Text Too Small on Mobile Body text should be at least 16px. Test your site on a real phone. If you have to pinch to zoom, your text is too small.
No Visual Hierarchy Headings should be noticeably bigger and bolder than body text. If everything looks the same size, readers can't scan the page.
Lines Too Long Aim for 60-80 characters per line. Long lines are exhausting to read. Use max-w-prose or max-w-2xl to limit line width.
Not Enough Line Height Body text needs breathing room between lines. Use leading-normal (1.5) or leading-relaxed (1.625) for comfortable reading.
ALL CAPS for Body Text Uppercase is great for short labels and badges, but terrible for paragraphs. It slows reading speed by 10-20%. Save it for small elements.

HTML Text Elements

Every text element on a webpage has a specific tag. Knowing the names helps you tell AI exactly what you want.

Live example
Headings (h1 – h6)
h1Page Title
h2Section Title
h3Sub-section
h4Card Title
h5Small Heading
h6Label Heading

Use only one h1 per page (the main title). h2 for major sections, h3 for sub-sections inside those. Don't skip levels.

Live example
Body Text & Inline Styles
pThis is a normal paragraph. Most of your content uses this tag.
strongBold text: use for important words or emphasis.
emItalic text: use for emphasis, titles, or foreign words.
smallSmall text: captions, footnotes, fine print.
aLink text: clickable text that goes somewhere.
codeInline code: for technical terms or code snippets.
blockquote"A quote from someone else."
Live example
Lists
ul: Unordered (bullet) list
  • First item
  • Second item
  • Third item
ol: Ordered (numbered) list
  1. Step one
  2. Step two
  3. Step three

Prompt This

Copy-paste these prompts into your AI tool to apply what you just learned.

SET UP A TYPOGRAPHY SYSTEM

“Set up a typography system for my app using [font name] for headings and [font name] for body text. Include sizes for h1-h4, body, small text, and captions. Use consistent line heights and letter spacing.”

ADD GOOGLE FONTS

“Import and apply Google Fonts to my Next.js project. Use [heading font] for all headings and [body font] for paragraph text. Make sure the fonts load efficiently and have proper fallbacks.”

FIX TEXT READABILITY

“My page text is hard to read. Fix the typography: make body text at least 16px, set line height to 1.5 for paragraphs, limit line width to about 65 characters, and add clear visual hierarchy between headings and body text.”

Frequently Asked Questions

How many fonts should I use on my site?

Two is the sweet spot, one for headings and one for body text. Using more than two fonts makes your site look cluttered. Some great sites use just one font family and vary the weight (bold, regular, light) for contrast.

What's the difference between serif and sans-serif?

Serif fonts have small decorative strokes at the ends of letters (like Times New Roman). Sans-serif fonts are clean and simple (like Arial or Inter). Sans-serif is the default choice for most websites because it's easier to read on screens.

What font size should I use for body text?

16px is the standard minimum for body text on the web. Anything smaller is hard to read on phones. For headings, 24-48px works well depending on the importance. Let your AI tool set up a consistent size scale.