Web Typography
name: web-typography description: Generate production-grade web typography CSS with correct sizing, spacing, font loading, and responsive behavior based on Butterick's Practical Typography
-
Body text first. Always start with the body font. Set its size (16-20px for web), line-height (1.3-1.45 as unitless value), and max-width (~65ch or 45-90 characters per line). Everything else derives from this.
-
Build a type scale. Use 1.2-1.5x ratio steps from the base size. Do not pick arbitrary heading sizes. Example at 18px base with 1.25 ratio: body 18px, H3 22px, H2 28px, H1 36px. Clamp to these values.
-
Font selection rules:
- NEVER default to Arial, Helvetica, Times New Roman, or system-ui without explicit justification
- Pair fonts by contrast (serif body + sans heading, or vice versa), never by similarity
- Max 2-3 font families total
- Prioritize fonts with generous x-height, open counters, and distinct Il1/O0 letterforms
- Free quality options: Source Serif, IBM Plex, Literata, Charter, Inter (headings only)
-
Font loading (MUST include):
font-display: swapon every@font-face<link rel="preload" as="font" type="font/woff2" crossorigin>for the body font- WOFF2 format only
- Subset to used character ranges when possible
- Variable fonts when 2+ weights/styles are needed from the same family
- Metrics-matched system font fallback to minimize CLS
-
Responsive typography:
- Use
clamp()for fluid sizing:clamp(1rem, 0.9rem + 0.5vw, 1.25rem)for body - NEVER use
vwunits alone (breaks user zoom, accessibility violation) - Line length drives breakpoints, not the other way around
- Test at 320px mobile and 1440px desktop
- Use
-
CSS properties (MUST apply):
font-kerning: normal(always on)font-variant-numeric: tabular-numson data/number columns,oldstyle-numsfor prosetext-wrap: balanceon headings (prevents orphan words)text-wrap: prettyon body textfont-optical-sizing: autofor variable fontshyphens: autowithlangattribute on<html>for justified textletter-spacing: 0.05-0.12emONLY ontext-transform: uppercaseelements- NEVER add
letter-spacingto lowercase body text
-
Spacing rules:
- Paragraph spacing via
margin-bottomequal to one line-height, no first-line indent for web - Headings: space-above at least 2x space-below (associates heading with its content)
- Bold not italic for headings. Subtle size increases (1.2-1.5x steps, not 2x jumps)
- Max 3 heading levels. If you need H4+, restructure the content.
- Paragraph spacing via
<output_format> Deliver CSS/Tailwind code with:
- Font loading strategy (@font-face or Google Fonts link with display=swap)
- Base typography variables (--font-body, --font-heading, --font-size-base, --line-height-base, --measure)
- Type scale (H1-H3 + body + small/caption)
- Responsive clamp() values
- Utility classes or direct styles for special cases (caps, tabular numbers, balanced headings) </output_format>
使用建议
- 想直接看效果?在「变量填充 / 测试」里点「测试效果」,AI 会返回真实结果;满意再「复制结果」。存在「我的版本」时可分别测试、并排对比。
- 也可点「复制提示词」直接复制原文,手动替换占位符。
- 把内容粘贴到对应 AI 模型(ChatGPT)的对话框。
- 想改成自己的版本?切到「编辑我的版本」,保存私有版本或公开提交。
标签
相似提示词
同分类下其他优质提示词
Git操作·危险操作自检
执行危险 Git 命令前的自检:确认影响范围、备份、替代方案与恢复路径。
Git操作·一条龙
Git 全流程打包:状态分析+步骤命令+风险警示+验证+恢复方案+提交规范。
API文档·OpenAPI版
输出 OpenAPI/Swagger 规范:paths/schemas/参数/响应完整 YAML 骨架。
Git操作·commit规范版
写规范提交:Conventional Commits,拆分提交、写清 body 与关联 issue。
代码生成·异常边界处理版
专补健壮性:列出边界/异常并逐一处理,给出防御性实现。
正则表达式·方言适配版
同一需求给多语言正则:JS/Python/PCRE/Go 的语法差异与兼容写法。