CSS Multi-line Typewriter
Two lines of monospace text typed out one after the other, with the caret moving down a line.
Design faster. Ship sooner.
<p class="tw-lines">
<span>Design faster.</span>
<span>Ship sooner.</span>
</p>
/* Set --n on each line to its number of characters */
.tw-lines {
margin: 0;
color: #1c1917;
font: 600 22px/1.5 ui-monospace, Menlo, monospace;
}
.tw-lines span {
display: block;
width: calc(var(--n) * 1ch);
overflow: hidden;
white-space: nowrap;
border-right: 0.12em solid transparent;
}
.tw-lines span:first-child {
--n: 14;
animation:
tw-lines-type 1.4s steps(14) both,
tw-lines-blink 0.7s step-end 2;
}
.tw-lines span:last-child {
--n: 12;
animation:
tw-lines-type 1.2s 1.6s steps(12) both,
tw-lines-blink 0.8s 1.4s step-end infinite;
}
@keyframes tw-lines-type {
from { width: 0; }
}
@keyframes tw-lines-blink {
from { border-right-color: currentColor; }
50% { border-right-color: transparent; }
}
@media (prefers-reduced-motion: reduce) {
.tw-lines span { animation: none; }
}
About this CSS Multi-line Typewriter
This CSS Multi-line Typewriter is 41 lines of pure CSS (0.8 KB) with no JavaScript and no dependencies. It uses keyframe animations, 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
Change these custom properties to restyle the multi-line typewriter without touching the rest of the CSS:
| Property | Default |
|---|---|
--n | 14 |
How to use this multi-line typewriter
- 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-linesclass 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.