CSS Text Spacing Generator
Adjust letter and word spacing for better readability
Presets
Default browser text spacing
Target Element
Selector: pLetter Spacing
Word Spacing
Line Height
Text Indent
White Space
Collapses whitespace, wraps textPreview Width
Live Preview
The quick brown fox jumps over the lazy dog. Typography is the art and technique of arranging type to make written language legible, readable, and appealing when displayed. The arrangement of type involves selecting typefaces, point sizes, line lengths, line-spacing (leading), and letter-spacing (tracking).
Before & After Comparison
Default Spacing
The quick brown fox jumps over the lazy dog. Typography is the art and technique of arranging type to make written language legible, readable, and appealing when displayed.
Your Settings
The quick brown fox jumps over the lazy dog. Typography is the art and technique of arranging type to make written language legible, readable, and appealing when displayed.
Spacing Examples
Typography spacing affects readability.
Typography spacing affects readability.
Typography spacing affects readability.
Typography matters
Generated CSS
p {
}/* Text Spacing - Normal */
p {
/* Letter Spacing: Space between characters */
letter-spacing: 0;
/* Word Spacing: Space between words */
word-spacing: 0;
/* Line Height: Space between lines */
line-height: 1.5;
/* Text Indent: First line indentation */
text-indent: 0;
/* White Space: Whitespace handling */
white-space: normal;
/* Text Wrap: Line wrapping behavior */
text-wrap: wrap;
/* Tab Size: Tab character width */
tab-size: 4;
-moz-tab-size: 4;
/* Hanging Punctuation: Punctuation outside text box */
hanging-punctuation: none;
}Code Examples
Headlines with Tight Tracking
h1, h2, h3 {
letter-spacing: -0.03em;
line-height: 1.1;
word-spacing: normal;
}
/* Larger headlines can be even tighter */
.display-heading {
letter-spacing: -0.05em;
line-height: 0.95;
}Body Text Optimization
body {
letter-spacing: 0.01em;
word-spacing: 0.02em;
line-height: 1.6;
}
/* First paragraph indent */
article p + p {
text-indent: 1.5em;
}
/* No indent after headings */
article h2 + p {
text-indent: 0;
}All Caps Text
.uppercase {
text-transform: uppercase;
letter-spacing: 0.1em;
word-spacing: 0.15em;
font-weight: 500;
}
/* Small caps variation */
.small-caps {
font-variant: small-caps;
letter-spacing: 0.05em;
}Responsive Typography
/* Mobile: tighter spacing */
.content {
letter-spacing: normal;
word-spacing: normal;
line-height: 1.5;
}
/* Desktop: slightly looser */
@media (min-width: 768px) {
.content {
letter-spacing: 0.01em;
word-spacing: 0.03em;
line-height: 1.7;
}
}Text Wrap Balance (Modern CSS)
/* Balance headlines for even line lengths */
h1, h2 {
text-wrap: balance;
max-width: 25ch;
}
/* Pretty wrap avoids orphans */
p {
text-wrap: pretty;
}
/* Fallback for unsupported browsers */
@supports not (text-wrap: balance) {
h1, h2 {
max-width: 20ch;
}
}Code Block Formatting
pre, code {
font-family: 'Fira Code', monospace;
tab-size: 2;
-moz-tab-size: 2;
white-space: pre;
letter-spacing: 0;
line-height: 1.6;
}
/* Inline code */
:not(pre) > code {
letter-spacing: -0.02em;
padding: 0.1em 0.3em;
}CSS Properties Reference
Text Spacing Properties
| Property | Values | Description |
|---|---|---|
letter-spacing | normal | length | Space between characters |
word-spacing | normal | length | Space between words |
line-height | normal | number | length | % | Space between lines |
text-indent | length | % | hanging | each-line | First line indentation |
white-space | normal | nowrap | pre | pre-wrap | pre-line | Whitespace handling |
text-wrap | wrap | nowrap | balance | pretty | Line wrapping behavior |
tab-size | integer | length | Tab character width |
hanging-punctuation | none | first | last | allow-end | force-end | Punctuation outside text box |
Browser Support
| Property | Chrome | Firefox | Safari | Edge |
|---|---|---|---|---|
| letter-spacing | 1+ | 1+ | 1+ | 12+ |
| word-spacing | 1+ | 1+ | 1+ | 12+ |
| line-height | 1+ | 1+ | 1+ | 12+ |
| text-indent | 1+ | 1+ | 1+ | 12+ |
| white-space | 1+ | 1+ | 1+ | 12+ |
| text-wrap: balance | 114+ | 121+ | 17.5+ | 114+ |
| text-wrap: pretty | 117+ | Not yet | Not yet | 117+ |
| tab-size | 21+ | 4+ | 6.1+ | 79+ |
| hanging-punctuation | Not yet | Not yet | 10+ | Not yet |
Recommended Spacing Values
| Use Case | Letter Spacing | Word Spacing | Line Height |
|---|---|---|---|
| Headlines | -0.02em to -0.05em | normal | 1.0 - 1.2 |
| Body Text | normal to 0.02em | normal to 0.05em | 1.5 - 1.7 |
| All Caps | 0.08em to 0.15em | 0.1em to 0.2em | 1.3 - 1.5 |
| Small Text | 0.02em to 0.05em | 0.03em to 0.08em | 1.6 - 1.8 |
| Navigation | 0.03em to 0.08em | normal | 1.2 - 1.4 |
| Code | normal | normal | 1.5 - 1.7 |
Best Practices
- Use relative units: Prefer em for letter-spacing and word-spacing so spacing scales with font size
- Tighten headlines: Large display text benefits from negative letter-spacing to reduce visual gaps
- Widen all caps: Uppercase text needs extra tracking (0.08-0.15em) to improve legibility
- Unitless line-height: Use unitless values (like 1.5) for line-height to scale properly with font size
- Balance wrapping: Use text-wrap: balance for headings to create even line lengths
- Consider reading context: Longer text blocks need more line-height; shorter text can be tighter
- Test at multiple sizes: Spacing that looks good at one size may not work at others
- Don't over-space: Excessive letter-spacing can hurt readability as much as too little
Accessibility Considerations
- Minimum line-height: Use at least 1.5 for body text (WCAG 1.4.12)
- Avoid justification: Full justification can create uneven word spacing, hindering readability
- Allow user override: Don't use !important on text spacing properties
- Test with zoom: Ensure spacing still works at 200% zoom
- Paragraph spacing: Consider using margin-bottom: 1em or more between paragraphs
- Word spacing: WCAG recommends allowing word-spacing of at least 0.16em