🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

Letter-spacing

AI & DATA SCIENCE // letter-spacing

The letter-spacing property adjusts the horizontal spacing between individual characters within text, accepting a length value that can be positive to spread letters apart or negative to tighten them.

Syntax

letter-spacing: normal | length;

Deep Dive Course

letter-spacing adds, or with a negative value, removes, a fixed amount of extra space between every pair of adjacent characters uniformly, distinct from word-spacing, which specifically adjusts the space between whole words rather than individual letters. A small positive value is commonly used to open up all-caps text, since uppercase letters set with default spacing can look visually cramped, while an aggressively large or negative value can meaningfully hurt readability, especially for body text meant to be read at length rather than a short, stylistic heading or label.

1Understanding Letter-spacing

letter-spacing adds, or with a negative value, removes, a fixed amount of extra space between every pair of adjacent characters uniformly, distinct from word-spacing, which specifically adjusts the space between whole words rather than individual letters. A small positive value is commonly used to open up all-caps text, since uppercase letters set with default spacing can look visually cramped, while an aggressively large or negative value can meaningfully hurt readability, especially for body text meant to be read at length rather than a short, stylistic heading or label.

💡

Pair a small positive letter-spacing, like 0.05em to 0.1em, specifically with uppercase or all-caps text — capital letters set at default spacing often look visually cramped, and a little extra letter-spacing typically improves their appearance noticeably.

editor.html
.badge {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
localhost:3000

2Practical Example

Here is a real-world application of Letter-spacing showing how it is used in production CSS code.

editor.html
.tight-heading {
  letter-spacing: -0.02em;
}
localhost:3000

3Best Practices

Follow these guidelines when working with Letter-spacing:

1. Add a small positive letter-spacing to uppercase or all-caps text specifically, since capital letters commonly look cramped without a bit of extra breathing room

2. Use an em-based value for letter-spacing rather than a fixed pixel value, so the spacing scales proportionally with the text's own font-size

3. Avoid a large positive or negative letter-spacing on body text meant for extended reading, since it noticeably reduces readability and legibility at that scale

⚠️

Tip: Pair a small positive letter-spacing, like 0.05em to 0.1em, specifically with uppercase or all-caps text — capital letters set at default spacing often look visually cramped, and a little extra letter-spacing typically improves their appearance noticeably.

editor.html
.badge {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
localhost:3000

Examples

Example 01Basic Usage
.badge {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
Example 02Advanced Example
.tight-heading {
  letter-spacing: -0.02em;
}

Best Practices

  • Add a small positive letter-spacing to uppercase or all-caps text specifically, since capital letters commonly look cramped without a bit of extra breathing room
  • Use an em-based value for letter-spacing rather than a fixed pixel value, so the spacing scales proportionally with the text's own font-size
  • Avoid a large positive or negative letter-spacing on body text meant for extended reading, since it noticeably reduces readability and legibility at that scale

Interview Question

Why is letter-spacing commonly applied to uppercase text specifically, rather than being a general default improvement applied broadly to all text?

Hint: Think about how the visual shapes and spacing of capital letters differ from lowercase letters, and how that specifically interacts with a font's built-in default spacing.

Most fonts are primarily designed and spaced with the visual rhythm of mixed-case text in mind, where the varying heights, widths, and shapes of lowercase letters, along with ascenders and descenders, naturally create a certain visual spacing pattern that a font's default character spacing is tuned to complement. Uppercase letters, by contrast, are generally more uniform in height and often visually wider or blockier as a set, and when text is set entirely in capitals, that same default spacing, tuned for the more varied rhythm of mixed-case text, tends to look comparatively cramped and visually dense, since capital letters don't have the same natural visual breathing room that ascenders, descenders, and varied letter shapes provide in normal mixed-case text. A small amount of added letter-spacing specifically compensates for this, opening up the uniformly blockier capital letters to a more comfortable, evenly-spaced appearance, which is exactly why this technique is so commonly and specifically recommended for all-caps or uppercase text, rather than being treated as a universal improvement worth applying to ordinary mixed-case body text, which doesn't have this same cramped-by-default issue to correct.

Exercises

MediumPractice using Letter-spacing in a real scenario.
View Solution
.badge {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

Frequently Asked Questions

Why is letter-spacing commonly applied to uppercase text specifically, rather than being a general default improvement applied broadly to all text?

Most fonts are primarily designed and spaced with the visual rhythm of mixed-case text in mind, where the varying heights, widths, and shapes of lowercase letters, along with ascenders and descenders, naturally create a certain visual spacing pattern that a font's default character spacing is tuned to complement. Uppercase letters, by contrast, are generally more uniform in height and often visually wider or blockier as a set, and when text is set entirely in capitals, that same default spacing, tuned for the more varied rhythm of mixed-case text, tends to look comparatively cramped and visually dense, since capital letters don't have the same natural visual breathing room that ascenders, descenders, and varied letter shapes provide in normal mixed-case text. A small amount of added letter-spacing specifically compensates for this, opening up the uniformly blockier capital letters to a more comfortable, evenly-spaced appearance, which is exactly why this technique is so commonly and specifically recommended for all-caps or uppercase text, rather than being treated as a universal improvement worth applying to ordinary mixed-case body text, which doesn't have this same cramped-by-default issue to correct.

Related Functions

Text-transformWord-spacingFont-weight