AI CSS Animations

Word by Word Text Animation

Each word slides up out of its own hidden slot, tilted slightly, one after another. Every word is an overflow: hidden wrapper around a moving span, so the edge stays crisp.

Also known as: split words animation css, staggered word reveal, words slide up one by one.

Every word counts

HTML

<div class="txt-word-by-word-reveal"><span class="txt-word-by-word-reveal-w"><span style="--i: 0">Every</span></span> <span class="txt-word-by-word-reveal-w"><span style="--i: 1">word</span></span> <span class="txt-word-by-word-reveal-w"><span style="--i: 2">counts</span></span></div>

CSS

.txt-word-by-word-reveal {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--c);
  white-space: nowrap;}
/* the slot: clips the word while it is below the line */
.txt-word-by-word-reveal-w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding: 0 0.06em 0.08em;
  margin: 0 -0.06em -0.08em;
}
.txt-word-by-word-reveal-w > span {
  display: inline-block;
  transform-origin: 0 100%;
  animation: txt-word-by-word-reveal-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) calc(0.1s + var(--i) * 0.09s) both;
}
@keyframes txt-word-by-word-reveal-up {
  from { transform: translateY(110%) rotate(8deg); }
  to   { transform: translateY(0) rotate(0); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-word-by-word-reveal, .txt-word-by-word-reveal *, .txt-word-by-word-reveal::before, .txt-word-by-word-reveal::after, .txt-word-by-word-reveal *::before, .txt-word-by-word-reveal *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar text animations