typography

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Typography

排版设计

Professional typography for user interfaces, grounded in principles from the masters.
"Typography exists to honor content." — Robert Bringhurst
面向用户界面的专业排版设计,遵循业界大师的经典原则。
"排版设计的存在是为了尊重内容。" — 罗伯特·布林赫斯特

Reference Files

参考文档

For detailed guidance on specific topics, consult these references:
TopicWhen to Read
masters.mdSeeking authoritative backing, making nuanced judgments, understanding "why"
variable-fonts.mdUsing variable fonts, fluid weight, performance optimization
font-loading.mdFOIT/FOUT issues, preloading, Core Web Vitals, self-hosting
opentype-features.mdLigatures, tabular numbers, stylistic sets, slashed zero
fluid-typography.mdclamp(), text-wrap, truncation, vertical rhythm, font smoothing
tailwind-integration.mdTailwind typography utilities, prose plugin, customization
internationalization.mdRTL languages, Arabic/Hebrew, CJK, bidirectional text
如需获取特定主题的详细指导,请查阅以下参考文档:
主题阅读场景
masters.md寻求权威依据、做出细致判断、理解设计背后的"原因"
variable-fonts.md使用可变字体、实现动态字重、优化性能
font-loading.md解决FOIT/FOUT问题、预加载优化、核心Web指标、自托管字体
opentype-features.md连字、表格数字、样式集、带斜线零等特性使用
fluid-typography.md使用clamp()、文本换行、截断、垂直韵律、字体平滑
tailwind-integration.mdTailwind排版工具类、prose插件、自定义配置
internationalization.mdRTL语言、阿拉伯语/希伯来语、CJK、双向文本处理

Output Formats

输出格式

Type System Recommendations

字体系统建议

markdown
undefined
markdown
undefined

Type System

字体系统

Scale

比例系统

  • Base: [size, e.g., 16px]
  • Ratio: [e.g., Minor Third 1.200]
  • Rationale: [why this ratio]
  • 基础字号:[示例:16px]
  • 比例系数:[示例:小三度 1.200]
  • 设计依据:[选择该比例的原因]

Hierarchy

层级结构

LevelSizeWeightLine HeightLetter SpacingUse
Display............Hero, marketing
H1............Page titles
H2............Section heads
Body............Paragraphs
Small............Captions, labels
层级字号字重行高字符间距适用场景
展示级............英雄区、营销文案
一级标题............页面标题
二级标题............区块标题
正文............段落文本
辅助文本............说明文字、标签

Fonts

字体选择

  • Primary: [font] — [rationale]
  • Secondary: [font, if applicable]
  • Mono: [font, if applicable]
  • 主字体:[字体名称] — [选择依据]
  • 次要字体:[如需搭配]
  • 等宽字体:[如需使用]

Implementation

实现代码

[Ready-to-use CSS/Tailwind]
undefined
[可直接使用的CSS/Tailwind代码]
undefined

Typography Audits

排版审计报告

markdown
undefined
markdown
undefined

Typography Audit

排版审计报告

Issues

问题清单

ElementProblemRecommendation
.........
元素问题描述优化建议
.........

Quick Wins

快速优化方案

  • [Immediate improvement 1]
  • [Immediate improvement 2]

---
  • [立即优化项1]
  • [立即优化项2]

---

Core Principles

核心原则

The Four Fundamentals (Bringhurst)

四大基础原则(布林赫斯特提出)

The most important typographic considerations for body text:
  1. Point size — 16px minimum for body; 14px absolute floor for secondary text
  2. Line spacing — 1.5-1.7 for body; 1.1-1.3 for headings
  3. Line length — 45-75 characters (66 ideal); use
    max-w-prose
    (~65ch)
  4. Font choice — Match typeface to content and context
正文文本最重要的排版考量因素:
  1. 字号 — 正文最小16px;次要文本绝对下限为14px
  2. 行高 — 正文行高1.5-1.7;标题行高1.1-1.3
  3. 行长 — 45-75个字符(理想值66);使用
    max-w-prose
    (约65ch)
  4. 字体选择 — 匹配字体与内容及场景

Hierarchy Through Contrast

通过对比构建层级

Establish hierarchy using multiple dimensions:
DimensionLow ContrastHigh Contrast
Size14px → 16px16px → 48px
Weight400 → 500400 → 700
ColorGray-600 → Gray-900Gray-400 → Black
CaseNormalUPPERCASE
"Use one typeface per design. Avoid italics and bold—rely on gradations of scale instead." — Massimo Vignelli
从多个维度建立排版层级:
维度低对比高对比
字号14px → 16px16px → 48px
字重400 → 500400 → 700
颜色灰600 → 灰900灰400 → 黑色
大小写常规全大写
"设计中仅使用一种字体。避免使用斜体和粗体——转而依靠字号比例的层级变化。" — 马西莫·维涅里

Restraint

克制原则

  • 1-2 font families maximum — One serif, one sans if pairing
  • 3-4 heading levels in practice — Deeper nesting usually signals structure problems
  • Stick to your type scale — Resist arbitrary sizes
  • Let whitespace work — Don't fill every gap
"In the new computer age, the proliferation of typefaces represents a new level of visual pollution." — Massimo Vignelli

  • 最多使用1-2种字体族——如需搭配,可选择一款衬线体和一款无衬线体
  • 实际使用3-4级标题层级——更深的嵌套通常意味着结构存在问题
  • 严格遵循字体比例系统——避免随意设置字号
  • 善用留白——不要填满每一处空隙
"在新的计算机时代,字体的泛滥代表着一种新的视觉污染。" — 马西莫·维涅里

Type Scales

字体比例系统

Modular Scale Ratios

模块化比例系数

NameRatioCharacter
Minor Second1.067Subtle, conservative
Major Second1.125Gentle, professional
Minor Third1.200Balanced, versatile
Major Third1.250Bold, impactful
Perfect Fourth1.333Strong hierarchy
Golden Ratio1.618Dramatic, editorial
名称比例特点
小二度1.067细微、保守
大二度1.125温和、专业
小三度1.200平衡、通用
大三度1.250醒目、有冲击力
纯四度1.333层级清晰
黄金比例1.618戏剧性、适合编辑类内容

Practical Scale (Minor Third @ 16px)

实用比例系统(小三度 @ 16px)

css
--text-xs:   12px;  /* 0.75rem */
--text-sm:   14px;  /* 0.875rem */
--text-base: 16px;  /* 1rem */
--text-lg:   18px;  /* 1.125rem — not in pure scale */
--text-xl:   20px;  /* 1.25rem */
--text-2xl:  24px;  /* 1.5rem */
--text-3xl:  30px;  /* 1.875rem */
--text-4xl:  36px;  /* 2.25rem */
--text-5xl:  48px;  /* 3rem */
css
--text-xs:   12px;  /* 0.75rem */
--text-sm:   14px;  /* 0.875rem */
--text-base: 16px;  /* 1rem */
--text-lg:   18px;  /* 1.125rem — 不属于纯比例系统 */
--text-xl:   20px;  /* 1.25rem */
--text-2xl:  24px;  /* 1.5rem */
--text-3xl:  30px;  /* 1.875rem */
--text-4xl:  36px;  /* 2.25rem */
--text-5xl:  48px;  /* 3rem */

When to Deviate

特殊场景调整

  • Marketing/hero: Larger jumps allowed
  • Dense data interfaces: Tighter scale
  • Mobile: Slightly larger base (17-18px)

  • 营销/英雄区: 允许更大的字号跨度
  • 数据密集型界面: 使用更紧凑的比例系统
  • 移动端: 基础字号略大(17-18px)

Spacing Guidelines

间距指南

Line Height by Context

按场景设置行高

ContextLine HeightRationale
Body text1.5-1.7Generous for readability
Headings1.1-1.3Tighter, especially large sizes
UI labels1.2-1.4Compact but legible
Buttons1.0-1.25Single line, tight
"The eye does not read letters, but the space between them." — Adrian Frutiger
场景行高范围设计依据
正文1.5-1.7保证可读性
标题1.1-1.3紧凑、突出标题
UI标签1.2-1.4紧凑但清晰
按钮文本1.0-1.25单行文本、紧凑布局
"眼睛阅读的不是字母,而是字母之间的空间。" — 阿德里安·弗里蒂格

Letter Spacing

字符间距(字距调整)

ContextTrackingCSS
Body textDefault or +0.01em
tracking-normal
All caps+0.05em to +0.1em
tracking-wide
/
tracking-wider
Large headings-0.01em to -0.02em
tracking-tight
Small text (<14px)+0.01em to +0.02em
tracking-wide
All-caps rule: Always add tracking. Keep short (1-3 words).
场景字距设置CSS属性
正文默认或+0.01em
tracking-normal
全大写文本+0.05em至+0.1em
tracking-wide
/
tracking-wider
大标题-0.01em至-0.02em
tracking-tight
小文本(<14px)+0.01em至+0.02em
tracking-wide
全大写规则: 必须添加字距。文本长度控制在1-3个单词以内。

Paragraph Spacing

段落间距

  • Between paragraphs: 1em to 1.5em (equal to or slightly more than line-height)
  • After headings: Reduced top margin on first paragraph
  • Between sections: 2-3× paragraph spacing

  • 段落之间: 1em至1.5em(等于或略大于行高)
  • 标题之后: 第一段的上边距缩小
  • 区块之间: 2-3倍段落间距

Font Selection

字体选择

System Font Stacks

系统字体栈

css
/* Sans-serif (modern) */
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

/* Serif */
font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;

/* Monospace */
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
css
/* 无衬线字体(现代风格) */
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

/* 衬线字体 */
font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;

/* 等宽字体 */
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

Safe Web Font Recommendations

安全的Web字体推荐

CategoryFontsUse Case
Sans-serifInter, Source Sans 3, Work Sans, DM SansUI, body text
SerifSource Serif 4, Lora, Merriweather, LiterataEditorial, long-form
MonospaceJetBrains Mono, Fira Code, Source Code ProCode, data
DisplayFraunces, Epilogue, OutfitHeadlines
类别推荐字体适用场景
无衬线字体Inter、Source Sans 3、Work Sans、DM SansUI界面、正文文本
衬线字体Source Serif 4、Lora、Merriweather、Literata编辑类内容、长文本
等宽字体JetBrains Mono、Fira Code、Source Code Pro代码、数据展示
展示字体Fraunces、Epilogue、Outfit标题、大字号文本

Pairing Principles

字体搭配原则

  • Pair by contrast — Serif + sans-serif
  • Match x-height — For visual harmony when mixed
  • Ensure weight availability — Both need needed weights/styles
"A father should not have a favorite among his daughters." — Hermann Zapf (on his typefaces)

  • 通过对比搭配——衬线体+无衬线体
  • 匹配x高度——混合使用时保证视觉和谐
  • 确保字重可选——两款字体都需具备所需的字重和样式
"父亲不应偏爱自己的任何一个女儿。" — 赫尔曼·扎普夫(谈及他设计的字体)

Modern CSS Typography

现代CSS排版技术

Text Wrapping

文本换行优化

css
/* Balanced line lengths for headings (≤6 lines) */
h1, h2, h3, blockquote, figcaption {
  text-wrap: balance;
}

/* Prevent orphans in body text */
p, li {
  text-wrap: pretty;
}
Caveat: Don't use
balance
inside bordered containers—creates visual imbalance.
css
/* 为标题平衡行宽(≤6行文本) */
h1, h2, h3, blockquote, figcaption {
  text-wrap: balance;
}

/* 避免正文出现孤行 */
p, li {
  text-wrap: pretty;
}
注意: 不要在带边框的容器内使用
balance
——会造成视觉不平衡。

Fluid Typography

流体排版

css
/* Font scales smoothly between breakpoints */
h1 {
  font-size: clamp(2rem, 1rem + 4vw, 4rem);
  line-height: clamp(1.1, 1.3 - 0.1vw, 1.3);
}

body {
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
}
See fluid-typography.md for complete scale.
css
/* 字体在断点间平滑缩放 */
h1 {
  font-size: clamp(2rem, 1rem + 4vw, 4rem);
  line-height: clamp(1.1, 1.3 - 0.1vw, 1.3);
}

body {
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
}
详见fluid-typography.md获取完整比例系统。

Text Truncation

文本截断

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

/* Multi-line (2 lines) */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

css
/* 单行截断 */
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 多行截断(2行) */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

Dark Mode Typography

深色模式排版

Weight Adjustment

字重调整

Text appears heavier on dark backgrounds. Reduce weight slightly:
css
@media (prefers-color-scheme: dark) {
  body {
    font-weight: 350; /* Instead of 400 */
  }
  h1, h2, h3 {
    font-weight: 600; /* Instead of 700 */
  }
}
深色背景下文本会显得更粗,需略微降低字重:
css
@media (prefers-color-scheme: dark) {
  body {
    font-weight: 350; /* 替代默认的400 */
  }
  h1, h2, h3 {
    font-weight: 600; /* 替代默认的700 */
  }
}

Font Smoothing

字体平滑

Apply antialiasing on dark backgrounds to counter perceived boldness:
css
.dark-bg {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
在深色背景上应用抗锯齿效果,抵消视觉上的加粗感:
css
.dark-bg {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

Color Contrast

颜色对比度

  • Avoid pure white (#fff) on pure black (#000)—too harsh
  • Use off-white (#f5f5f5) and near-black (#1a1a1a)
  • Aim for 10:1 to 15:1 contrast in dark mode

  • 避免纯白色(#fff)搭配纯黑色(#000)——过于刺眼
  • 使用米白色(#f5f5f5)和近黑色(#1a1a1a)
  • 深色模式下目标对比度为10:1至15:1

Typographic Details

排版细节

Quotation Marks

引号使用

Use curly quotes, not straight:
  • Correct: "Hello" and 'world'
  • Incorrect: "Hello" and 'world'
使用弯引号而非直引号:
  • 正确:“Hello” 和 ‘world’
  • 错误:"Hello" 和 'world'

Dashes

破折号使用

TypeCharacterUse
Hyphen-Word breaks, compounds
En dashRanges (2020–2024), relationships
Em dashParenthetical statements
类型字符用途
连字符-单词拆分、复合词
短破折号表示范围(2020–2024)、关系
长破折号插入语、补充说明

Numbers

数字格式

TypeUse CaseCSS
TabularTables, prices, alignment
font-variant-numeric: tabular-nums
ProportionalBody text
font-variant-numeric: proportional-nums
Old-styleEditorial content
font-variant-numeric: oldstyle-nums
Slashed zeroCode, data
font-feature-settings: "zero" 1
See opentype-features.md for complete reference.

类型适用场景CSS属性
表格数字表格、价格、对齐
font-variant-numeric: tabular-nums
比例数字正文文本
font-variant-numeric: proportional-nums
旧式数字编辑类内容
font-variant-numeric: oldstyle-nums
带斜线零代码、数据
font-feature-settings: "zero" 1
详见opentype-features.md获取完整参考。

Accessibility

无障碍设计

Minimums

最低标准

ElementMinimumPreferred
Body text16px16-18px
Secondary text14px14-16px
Legal/caption12px12px + increased tracking
Contrast ratio4.5:17:1
元素最低要求推荐标准
正文16px16-18px
次要文本14px14-16px
法律文本/说明文字12px12px + 增加字距
对比度4.5:17:1

User Preferences

尊重用户偏好

css
/* Use relative units so users can scale */
body {
  font-size: 1rem; /* Not 16px */
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
css
/* 使用相对单位,方便用户缩放文本 */
body {
  font-size: 1rem; /* 不要使用16px */
}

/* 尊重用户的减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

Dyslexia Considerations

阅读障碍友好设计

  • Avoid justified text
  • Prefer sans-serif with distinct letterforms (a vs α, l vs 1 vs I)
  • Generous line height and paragraph spacing
  • Consider offering OpenDyslexic as option

  • 避免两端对齐文本
  • 选择字母形态区分度高的无衬线字体(如a与α、l与1与I)
  • 增大行高和段落间距
  • 考虑提供OpenDyslexic字体作为选项

Common Mistakes

常见错误

Avoid

需避免的问题

  • All-caps body text or long headings
  • Centered body paragraphs
  • Line length over 80 characters
  • Insufficient contrast for "aesthetic" reasons
  • Mixing too many font families (>2)
  • Decorative fonts for UI text
  • Justified text on the web
  • Tiny gray text on white backgrounds
  • Letter-spacing on Arabic text
  • 正文或长标题使用全大写
  • 正文文本居中对齐
  • 行长超过80个字符
  • 为了“美观”牺牲对比度
  • 使用超过2种字体族
  • UI文本使用装饰性字体
  • Web端使用两端对齐文本
  • 白色背景上使用极小的灰色文本
  • 阿拉伯语文本添加字距调整

Watch For

需要注意的问题

  • Orphans and widows in prominent text
  • Inconsistent heading hierarchy
  • Missing font fallbacks
  • Layout shift from web font loading
  • Underlined text that isn't a link

  • 重要文本中出现孤行和widow
  • 标题层级不一致
  • 缺少字体降级方案
  • Web字体加载导致布局偏移
  • 非链接文本添加下划线

Quick Implementation

快速实现方案

Minimal Professional Setup

极简专业配置

css
:root {
  --font-sans: Inter, ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

body {
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.6;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}

h1, h2, h3 {
  line-height: 1.2;
  text-wrap: balance;
  letter-spacing: -0.02em;
}

p {
  text-wrap: pretty;
  max-width: 65ch;
}

code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums slashed-zero;
}

@media (prefers-color-scheme: dark) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}
css
:root {
  --font-sans: Inter, ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

body {
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.6;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}

h1, h2, h3 {
  line-height: 1.2;
  text-wrap: balance;
  letter-spacing: -0.02em;
}

p {
  text-wrap: pretty;
  max-width: 65ch;
}

code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums slashed-zero;
}

@media (prefers-color-scheme: dark) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

Tailwind Quick Start

Tailwind快速入门

html
<article class="
  prose prose-gray lg:prose-lg
  prose-headings:text-balance
  prose-p:text-pretty
  dark:prose-invert
  max-w-prose mx-auto
">
  <!-- Content -->
</article>
See tailwind-integration.md for complete patterns.
html
<article class="
  prose prose-gray lg:prose-lg
  prose-headings:text-balance
  prose-p:text-pretty
  dark:prose-invert
  max-w-prose mx-auto
">
  <!-- 内容 -->
</article>
详见tailwind-integration.md获取完整模式。",