CSS Typewriter Word Loop
A headline that types and deletes a list of words in turn, with a blinking caret and no JavaScript.
Make it fast simple yours
<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>
/* --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; }
}
About this CSS Typewriter Word Loop
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. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
The colors in this snippet. Search and replace them to match your brand:
#3b0764#c026d3
How to use this typewriter word loop
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.tw-loopclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.