# Multi-line Typewriter

> Two lines of monospace text typed out one after the other, with the caret moving down a line.

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

## HTML

```html
<p class="tw-lines">
  <span>Design faster.</span>
  <span>Ship sooner.</span>
</p>
```

## CSS

```css
/* 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; }
}
```

## Notes

- 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.
- Customize with: `--n`.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
