CSS Wavy Text Animation
Letters that rise and fall in a staggered wave, and speed up under the pointer.

A wavy text animation moves each letter up and down a few pixels, delayed from its neighbor, so a sine wave appears to run through the word. It is one of the most-copied text effects because the CSS is short and the result is obvious. It is also easy to overuse. A wave through a headline is a gesture. A wave through a paragraph is unreadable.
The demo sets “Wave the line” as separate spans. --i is the index. animation-delay: calc(var(--i) * 0.08s) is the wave. Hover shortens the duration and shifts the color, so the same animation has a resting state and a pointed state.
See also animating text on hover and the neon text if the wave is the wrong mood.
Markup from a string
You can write the spans by hand. Generating them keeps the headline source as one string and avoids a span around every letter in your CMS output.
const text = "Wave the line";
[...text].forEach((char, index) => {
const span = document.createElement("span");
span.textContent = char === " " ? "\u00a0" : char;
span.style.setProperty("--i", String(index));
line.append(span);
});
Use a non-breaking space for gaps. A normal space inside an inline-block span collapses. Put aria-label on the heading equal to the full phrase, because some browsers expose the spans as a run of separate letters. The label gives the heading one name.
The wave
h1 span {
display: inline-block;
animation: wave 1.6s ease-in-out infinite;
animation-delay: calc(var(--i) * 0.08s);
}
h1:hover span { animation-duration: 0.7s; color: #c2410c; }
@keyframes wave {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-0.28em); }
}
inline-block is required. Transforms do not apply to a bare inline box the way you expect. The distance is in em so the wave scales with the type. -0.28em is enough to see and small enough that the line box does not collide with the line above. If the heading clips, the parent needs a little padding. Transforms do not grow the layout box, and a parent with overflow: hidden will cut the crest of the wave.
ease-in-out is the right curve. Linear makes the letter bang into the top and bottom. A bounce makes it feel like a jumping bean, which is a different snippet.
Hover, focus, and reduced motion
:hover speeding the wave is a fine enhancement on a pointer device. Also match :focus-visible if the heading is inside a link, so keyboard users get the same response when they land on it. This demo’s heading is not a link. The color shift is the hover, and the wave already runs.
Under prefers-reduced-motion: reduce, set animation: none on the spans. The letters sit on the baseline. The sentence remains.
Where it works
A short title, a poster word, a 404, a music or fashion lockup. It does not work on navigation, buttons with more than one word of instruction, or any text a person must read carefully while it moves. If the wave runs forever next to a form, move it or gate it behind hover only:
h1 span { animation: none; }
h1:hover span { animation: wave 0.7s ease-in-out infinite; }
The demo runs it always because the page is the effect. On a marketing page, hover-only is the politer default.
Questions about wavy text
How do I make wavy text in CSS?
Wrap each letter in a span, display them inline-block, and animate translateY with a delay of about 0.08s times the letter index. The stagger is what turns identical bounces into a wave.
Why are the spaces missing in my wave?
An inline-block span that contains a normal space can collapse. Put a non-breaking space in the empty letters, or give those spans a width.
Can the wave be pure CSS without generating spans?
Only if you are willing to write the spans in the HTML. CSS cannot split a text node into animatable letters. A build step or ten lines of script can do it. Hand-authored spans are fine for a headline that rarely changes.