December 4, 2026
To animate a headline word by word without GSAP, wrap each word in a pair of spans, hide the inner span below a clipping edge, and slide it up with a delay based on the word's position. A few lines of JavaScript do the splitting and CSS does the motion. The free Enrichr Library has several finished versions.
What is the code?
function splitWords(el) {
const text = el.textContent.trim();
el.setAttribute("aria-label", text);
el.innerHTML = text.split(/\s+/).map((word, i) =>
`<span class="w" aria-hidden="true"><span style="--i:${i}">${word}</span></span>`
).join(" ");
}
document.querySelectorAll(".split").forEach((el) => {
splitWords(el);
new IntersectionObserver(([entry], io) => {
if (entry.isIntersecting) { el.classList.add("is-in"); io.disconnect(); }
}, { threshold: 0.4 }).observe(el);
});
.split .w { display: inline-block; overflow: hidden; vertical-align: bottom; }
.split .w > span {
display: inline-block;
transform: translateY(110%);
transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
transition-delay: calc(var(--i) * 60ms);
}
.split.is-in .w > span { transform: none; }
@media (prefers-reduced-motion: reduce) {
.split .w > span { transform: none; transition: none; }
}
If the heading holds text you did not write, escape it before putting it into innerHTML, or build the spans with
document.createElement.
Why two spans per word?
The outer span is the mask. It has overflow: hidden and stays where the word belongs. The inner span starts just
below it and slides up into view. That is what makes the word look as if it rises out of a slot instead of fading in.
How do I split into letters?
const letters = [...new Intl.Segmenter().segment(word)].map((s) => s.segment);
Intl.Segmenter keeps emoji and combined characters in one piece. Keep each word in its own
inline-block wrapper with the letters inside, or the browser may break a line in the middle of a word.
What goes wrong most often?
- Screen readers read fragments. The
aria-labelon the heading andaria-hiddenon the pieces fix that. - Descenders get cut off. The mask clips the tails of "g" and "y". Add a little
padding-bottomto the outer span and the same negativemargin-bottom. - The text flashes before it is split. Hide the heading with
visibility: hiddenuntil the script has run, and make sure it shows if the script fails.
Which finished examples can I copy?
| Element | What it does |
|---|---|
| Split text reveal | A headline whose words rise out of a mask one after another when it scrolls into view. |
| Letter pop intro | Each letter overshoots its size and settles, staggered left to right. |
| Hover lift type | Big uppercase type that rises into place letter by letter, then lifts under the pointer. |
| Stagger letter swap | Two screens of big type that swap, every character sliding out in a stagger. |
| Kinetic type reveals | Nine ways for a line of type to arrive. |
Where to go next
- How to make a text scramble effect.
- Scroll animations without a library.
- Recreate a GSAP scroll animation from a website.
FAQ
How do I split text into letters in JavaScript?
Use Array.from(text) or Intl.Segmenter rather than text.split(""). The plain split cuts emoji and some accented letters in half.
Is GSAP SplitText free?
Yes. GSAP and its plugins, including SplitText, are free to use now. See is GSAP free? for the terms. For a single headline, the plain version below is less code to load.
How do I animate text line by line?
Lines only exist after the browser has laid the text out. Split into words first, then group words that share the same offsetTop. You must redo this when the window is resized.
Does splitting text hurt SEO?
Search engines read the text content of the spans, so the words are still there. Keep the heading a real heading element and do not hide the text with display: none.