Letter animation in CSS means animating an individual character instead of a whole block of text. You get the effect by wrapping each character in its own element, usually a <span>, and giving those spans a delay that increases from one letter to the next. There is no CSS property that targets single characters inside a normal text node, so the markup is the real work; once the letters are separated, a handful of lines of CSS and a small script or a manual split is all the animation needs.
What You'll Need
- A text editor and a browser with developer tools (Chrome, Firefox, Safari or Edge all work).
- A basic HTML page with a linked CSS file, or a code playground that renders HTML and CSS.
- Comfort with CSS selectors,
@keyframesand theanimationshorthand. - Optionally, a few lines of JavaScript if you want the splitting done automatically rather than by hand.
- No framework or library is required. Everything below is plain HTML, CSS and vanilla JavaScript.
Step-by-Step
- Write the text you want to animate. Start with a single word or a short heading rather than a paragraph. A common choice is a hero heading such as
<h1 class="letters">HELLO</h1>. Keep the source text short while you build and test the effect; long strings make it harder to see timing problems. - Split the text into individual characters. Each letter must sit in its own element. For a short, fixed string, do it by hand:
<span>H</span><span>E</span><span>L</span>…. For anything longer or dynamic, split with JavaScript. A small script that reads the element's text, clears it, and appends one<span>per character is the usual approach. When you split, give each span an index so CSS can use it: either setspan.style.setProperty('--i', index)in the loop or add a class such asletter-0,letter-1. The CSS custom property route scales better because the stylesheet does not need one rule per letter. - Preserve spaces and accessibility. A space character in a span will collapse like normal whitespace, so either skip space characters entirely and let them render as gaps, or wrap them with
white-space: preon the parent. Give the original element a readable label: setaria-labelto the plain text andaria-hidden="true"on the individual spans, or screen readers may spell the word out letter by letter. - Make each letter an inline-block. Add
.letters span { display: inline-block; }. Transforms such astranslateYandrotateare ignored on plain inline elements, which is the single most common reason a letter animation appears to do nothing. - Define the keyframes. Write an
@keyframesblock describing the motion. A simple rise looks like@keyframes rise { from { opacity: 0; transform: translateY(0.5em); } to { opacity: 1; transform: translateY(0); } }. Keep the start and end states complete: animate opacity alongside the transform so letters do not pop in abruptly, and end on the element's resting position so nothing jumps when the animation finishes. - Apply the animation with a staggered delay. On the spans, set
animation: rise 0.6s ease both;andanimation-delay: calc(var(--i) * 60ms);. Thebothfill mode matters: it holds thefromstate before the delay elapses so letters are invisible rather than flashing in place, and it holds thetostate afterwards. Adjust the multiplier (60ms above) to change how tight or spread out the wave feels. - Test and tune in the browser. Reload the page and watch the sequence. If the stagger is too slow, lower the multiplier; if letters overlap too much, raise it or shorten each animation. Use the developer tools' animations panel to slow playback down so you can see exactly where each letter is in its cycle.
- Add a reduced-motion fallback. Wrap the animation in
@media (prefers-reduced-motion: no-preference) { … }, or explicitly reset the animation and delays under@media (prefers-reduced-motion: reduce)so the text is simply visible. Users who set that system option expect motion to stop, and a plain, fully rendered heading is the correct result for them. - Re-run the effect when you need it. A CSS animation runs once on load. To replay it on a click or when the element scrolls into view, remove and re-add a class in JavaScript (forcing a reflow between the two steps), or use an IntersectionObserver to add the class when the element becomes visible. This also prevents off-screen headings from finishing their animation before anyone sees them.
Common Mistakes
The most frequent failure is forgetting display: inline-block on the letter spans. The animation runs, but transforms have no visible effect, so the text just fades or does nothing at all. Check that first.
A second common error is leaving out the fill mode. Without both (or at least backwards), each letter displays normally during its delay and then snaps to the start of the keyframes when the animation begins. The result is a jarring flash of fully visible text followed by the animation.
Third, people animate a property that cannot be animated smoothly, such as display or height: auto, and wonder why the timing looks wrong. Animate opacity and transform instead; both are handled efficiently by the browser and look consistent.
Fourth, splitting text naively breaks words inside a span in ways that stop the browser wrapping at word boundaries, so a long heading overflows its container on small screens. Split on words as well as letters, or keep the container flexible and test at a narrow viewport.
Finally, screen reader users often hear the word spelled out. If the spans are not hidden from assistive technology and the parent does not carry the plain text as a label, the accessibility cost is real. Fix it before shipping.
Tips
Keep total duration honest. If a 10-letter word staggers at 100ms per letter, the last letter starts a full second after the first, and the whole effect can feel sluggish. A delay of 30–70ms per letter is usually enough for a light wave.
Use a single custom property for the index and let CSS do the arithmetic. Writing calc(var(--i) * 50ms) means you can retime the entire sequence by changing one number instead of editing dozens of rules.
Vary the animation direction with a second property for richer effects, for example alternating a small rotation for odd and even letters via :nth-child(odd) and :nth-child(even). This adds personality without more JavaScript.
Animate the same spans differently for hover states. Because you already have per-letter elements, a hover rule on the parent can set a new animation with a reversed delay, producing a wave in the opposite direction.
Keep the source text in the HTML rather than generating it entirely in JavaScript, so the heading still exists if scripts fail or are blocked.
Troubleshooting
If nothing happens at all, confirm the CSS file is loading, the class name on the element matches the selector, and the spans actually exist in the rendered markup. Inspect one span in developer tools and check whether the animation and delay are listed under computed styles.
If the text is invisible and stays that way, the animation is probably holding a from state with opacity: 0 and never running, often because the keyframes name is misspelled or the animation-name does not match the @keyframes block. Check that the two names are identical.
If only the first letter animates while the rest appear instantly, the delay is not varying: verify that the index variable is actually set on each span and that the delay uses it. A loop that sets the property on the parent rather than each span produces exactly this symptom.
If letters jump back to their starting position when the animation ends, the to state is not the resting state, or the fill mode is missing. Add both and make sure to matches how the text should look at rest.
If the layout shifts as letters animate in, an animated transform is fine, but animating margins or widths will reflow the page. Switch those properties to transform and opacity.
Frequently Asked Questions
Can I animate letters with CSS alone, without JavaScript?
Yes, but only if each letter is already inside its own element. CSS cannot select individual characters of a text node, so hand-writing the spans or generating them with a short script is required. Once split, all the timing and motion is pure CSS.
Why do letters not move, only fade?
Almost always because the spans are inline. Add display: inline-block; transforms are ignored on inline elements.
How do I make the animation start when the text scrolls into view?
Use an IntersectionObserver to add an animating class when the element becomes visible, and give the letter spans their animation only under that class. The animation then begins at the right moment instead of on page load.
Does the effect hurt accessibility?
It can if the split spans are exposed to screen readers or if motion cannot be disabled. Hide the spans with aria-hidden, give the parent an aria-label with the plain text, and respect prefers-reduced-motion.
Can I use this on a whole paragraph?
Technically yes, but per-letter animation on long text is distracting and generates many elements. Reserve it for short headings and callouts, and animate whole lines or words for body copy.