Revealing Text With CSS Letter-Spacing: Creative Animation Tricks You Can Use Today
CSS text effects can be surprisingly tricky. One of the biggest limitations developers face is the inability to target individual characters directly in CSS. While a hypothetical ::nth-letter() selector would be a dream come true, we do have some powerful tools available right now that can produce eye-catching results.
One of those tools is the humble letter-spacing property — and it’s more versatile than most developers realize.
What Is CSS letter-spacing?
The letter-spacing property controls the spacing between characters in a block of text. It accepts standard CSS length units as well as percentage values relative to the current font size.
Here’s what makes it especially useful for animations:
- Positive values add space to the right side of each character (in left-to-right writing modes).
- Negative values shrink the glyph box, causing letters to overlap — and even move in reverse.
- It is fully animatable, meaning you can transition smoothly between values.
That animatable quality is the key that unlocks a whole category of creative text reveal effects.
The Core Concept: Collapsing and Expanding Text
The foundational trick is straightforward. You start by completely collapsing the text using a large negative letter-spacing value and setting the color to transparent so it’s visually hidden:
label {
letter-spacing: -1ch;
color: transparent;
}
Then, you reveal the text by animating letter-spacing back to a normal value and restoring the color — for example, when a checkbox is checked:
input:checked + label {
letter-spacing: 0ch;
color: black;
transition: letter-spacing 0.6s, color 0.4s;
}
The result is a smooth, elegant text reveal that feels polished and intentional.
Quick note on the ch unit: It’s a relative CSS length unit representing the width of the “0” (zero) glyph in the current font. It’s a handy unit for character-based spacing calculations.
Text Alignment and Reveal Direction
One clever bonus of this technique is how text alignment interacts with the collapse effect. When you apply a negative letter-spacing, the letters bunch up at whatever alignment anchor you’ve set:
- Left-aligned text collapses toward the left.
- Center-aligned text collapses toward the center.
- Right-aligned text collapses toward the right.
When the spacing animates back to zero, the letters fan out from that same anchor point. This creates a natural, directional reveal effect that you can control simply by changing the text-align property.
Building an Interactive Show/Hide Toggle
This technique really shines in interactive UI elements. Consider a checkbox that swaps one message for another when toggled. Here’s the basic HTML structure:
<input type="checkbox" id="cb">
<label for="cb">
<span>Join the global club</span>
<span>You've begun your journey!</span>
</label>
The CSS uses overflow: clip on the label to clip any overflowing content, ensuring collapsed text stays hidden:
label {
overflow: clip;
}
span:nth-of-type(1) {
letter-spacing: 0ch;
:checked + * & {
letter-spacing: -2ch;
text-indent: -1.5ch;
transition: 0.4s letter-spacing cubic-bezier(.8, -.5, .2, 1.4),
0.1s text-indent;
}
}
span:nth-of-type(2) {
letter-spacing: -1ch;
color: transparent;
:checked + * & {
letter-spacing: 0ch;
color: black;
transition:
0.4s letter-spacing cubic-bezier(.8, -.5, .2, 1.4) 0.3s,
0.8s color 0.4s;
}
}
When the checkbox is checked, the first span collapses and slides out of view using a combination of negative letter-spacing and text-indent. At the same time, the second span expands from collapsed letters into full readable text.
Notice the use of a custom cubic-bezier curve to give the animation a bouncy, playful feel. A small transition delay on the second span ensures it starts appearing just as the first span begins to disappear — creating a seamless swap effect.
Combining letter-spacing With ::first-letter for Acronym Reveals
Here’s where things get really interesting. You can pair letter-spacing with the ::first-letter pseudo-element to create an acronym that expands into its full text on hover.
The markup wraps each word in its own <span>:
<p id="acronym">
<span class="words">United</span>
<span class="words">Nations</span>
<span class="words">International</span>
<span class="words">Children's</span>
<span class="words">Emergency</span>
<span class="words">Fund</span>
</p>
The CSS hides all characters except the first letter of each word:
.words {
letter-spacing: -1ch;
color: transparent;
&::first-letter {
color: black;
}
figure:hover + #acronym & {
letter-spacing: 0ch;
color: black;
transition: letter-spacing 0.4s cubic-bezier(.8, -.5, .2, 1.4);
}
}
By default, each word collapses to show only its first letter — giving you the acronym. On hover, all words expand to reveal their full spelling. It’s a beautiful, purely CSS interaction that requires zero JavaScript.
This kind of effect would be perfect for tooltips, educational content, logo reveals, or anywhere you want to progressively disclose information in a visually engaging way.
Why This Technique Matters
CSS text effects have traditionally required JavaScript libraries or complex workarounds. What makes the letter-spacing approach so appealing is that it:
- Uses pure CSS — no JavaScript required.
- Is performant — CSS transitions are hardware-accelerated.
- Works with existing pseudo-elements like
::first-letterand::first-line. - Is highly customizable through easing curves, delays, and alignment.
- Degrades gracefully in environments where animations are reduced.
Accessibility Considerations
While these effects are visually impressive, always keep accessibility in mind:
- Ensure text remains readable to screen readers even when visually collapsed.
- Use
prefers-reduced-motionmedia queries to disable or tone down animations for users who are sensitive to motion. - Don’t rely solely on visual text reveals to communicate important information.
@media (prefers-reduced-motion: reduce) {
.words, label span {
transition: none;
}
}
What Else Can You Build?
These examples only scratch the surface. With creative combinations of letter-spacing, text-indent, overflow: clip, ::first-letter, and CSS transitions, the possibilities are wide open.
Could you build a password-style reveal effect? A loading animation? A text-based game interaction? The constraints are real, but working within them often leads to the most inventive solutions.
For a deeper dive into all the examples shown here, check out the original article on CSS-Tricks where you can interact with live CodePen demos and explore the full code.
Level Up Your CSS Toolkit
Mastering small but powerful CSS properties like letter-spacing is exactly the kind of skill that separates good developers from great ones. When you understand your tools deeply, you find creative solutions where others see dead ends.
Looking for more tips, tools, and techniques to sharpen your workflow and boost your productivity? Visit myproductivetools.com — your go-to resource for developer productivity, design tools, and web development insights that help you work smarter every day.