# Typewriter Word Loop

> A headline that types and deletes a list of words in turn, with a blinking caret and no JavaScript.

- Category: [CSS Text Effects](https://copy-css.com/category/text)
- Tags: typing, rotating words, hero, headline, caret, steps
- Live preview: https://copy-css.com/snippets/typewriter-word-loop
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<h2 class="tw-loop">Make it
  <span class="tw-loop-words">
    <span style="--n: 4">fast</span>
    <span style="--n: 6">simple</span>
    <span style="--n: 5">yours</span>
  </span>
</h2>
```

## CSS

```css
/* --n is each word's character count. 3 words x 3s each = 9s */
.tw-loop {
  margin: 0;
  color: #3b0764;
  font: 700 28px/1.3 ui-monospace, Menlo, monospace;
}

.tw-loop-words {
  display: inline-grid;
  vertical-align: bottom;
  color: #c026d3;
  border-right: 0.1em solid;
  animation: tw-loop-blink 0.8s step-end infinite;
}

.tw-loop-words span {
  grid-area: 1 / 1;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  animation: tw-loop-type 9s steps(var(--n)) infinite;
}

.tw-loop-words span:nth-child(2) {
  animation-delay: 3s;
}

.tw-loop-words span:nth-child(3) {
  animation-delay: 6s;
}

@keyframes tw-loop-type {
  0% { width: 0; }
  12%, 24% { width: calc(var(--n) * 1ch); }
  33%, 100% { width: 0; }
}

@keyframes tw-loop-blink {
  50% { border-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .tw-loop-words,
  .tw-loop-words span { animation: none; }

  .tw-loop-words span:first-child { width: auto; }
}
```

## Notes

- This CSS Typewriter Word Loop is 47 lines of pure CSS (0.9 KB) with no JavaScript and no dependencies. It uses keyframe animations, CSS Grid, custom properties and reduced-motion support.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
