tools · 4 min read

CSS text animation: how to animate text with CSS, and when you need JavaScript

A CSS text animation moves text from one state to another with `@keyframes` or a `transition`: from transparent to visible, from lower down to its place, from blurred to sharp. For a whole heading that takes a few lines. For text that comes in letter by letter or word by word, each piece needs its own element and its own delay. Our text animation generator builds both: pick an effect, tune it while it plays, and export it as CSS only, one HTML file or a React component.

A text animation in plain CSS

The simplest one fades a heading up into place:

```css .title { animation: fade-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) both; } @keyframes fade-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } } ```

Three things make it look right:

  • Animate only `opacity`, `transform`, `filter` and `clip-path`. The browser can draw these without laying the page out again, so nothing jumps and the motion stays smooth.
  • Use an ease-out curve. Text that slows down as it lands reads as calm; a linear move reads as mechanical.
  • Keep it short. 0.6 to 1.2 seconds for a heading. Longer, and people wait for it.

Letter by letter and word by word

A stagger is the same animation on each letter or word, each starting a little after the last. CSS can't split text, so the markup has to do it:

```html <h1 class="stagger" aria-label="Type in motion"> <span aria-hidden="true" style="--i:0">Type</span> <span aria-hidden="true" style="--i:1">in</span> <span aria-hidden="true" style="--i:2">motion</span> </h1> ```

```css .stagger span { display: inline-block; animation: fade-up 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(var(--i) * 60ms); } ```

The `aria-label` on the heading and `aria-hidden` on the pieces mean a screen reader reads "Type in motion" once instead of letter by letter. `display: inline-block` is needed because transforms don't apply to plain inline text.

Reveals with masks and clip-path

A mask reveal slides text up from behind an edge, like a line rising out of a slot. Wrap each line in an element with `overflow: hidden` and move the line inside it from `translateY(100%)` to `0`. A wipe uses `clip-path: inset(0 100% 0 0)` and opens it to `inset(0 0 0 0)`. Both look sharper than a fade because the edge is crisp.

What CSS alone can't do

CSS plays fixed values. Some effects need numbers that only exist while the page runs:

  • Line-by-line reveals need to know where the browser broke the lines, which changes with every screen width.
  • Scramble, glitch and slot effects swap characters on every frame.
  • Typewriters with a human rhythm, and magnetic letters that follow the cursor, react to time and the pointer.
  • Scroll-scrubbed animations tie progress to scroll position. Scroll-driven animations in CSS are arriving, but not in every browser yet.

For these, a small script splits the text and drives the timeline. GSAP is the common choice and is free for commercial use. In the text animation generator, 14 of the 30 effects can export as CSS only. The rest export as HTML or React with the same engine the preview runs.

Respect reduced motion

Some people turn animations off in their system settings. Honour it:

```css @media (prefers-reduced-motion: reduce) { .title, .stagger span { animation: fade 0.2s both; } } @keyframes fade { from { opacity: 0; } } ```

A short fade, or no motion at all, keeps the page readable for everyone.

Make one without writing the keyframes

  1. Open the text animation generator and pick an effect. Each card plays when you hover over it.
  2. Type your text and set the font, timing, easing, stagger and trigger: on load, on scroll, on hover or on click.
  3. Check it at desktop, tablet and phone widths, then export CSS only for a no-JavaScript version, or HTML or React for any effect.

For type that moves as the whole message, not just its entrance, see kinetic typography.

FAQ

How do I animate text with CSS?

Use `@keyframes` to move the text from a start state (transparent, lower, blurred) to its final one, and apply it with `animation`. Animate opacity, transform, filter or clip-path only.

How do I animate each letter separately?

Wrap each letter or word in its own `span`, make it `inline-block`, and give each a growing `animation-delay`. Keep the full text in an `aria-label` for screen readers.

Do I need JavaScript for text animations?

Not for fades, slides, staggers and simple reveals. Effects that measure lines, swap characters or follow the cursor need a script.

Will my text animation work on phones?

Yes, if you set sizes and spacing per breakpoint and animate only transform, opacity, filter and clip-path.