Web Animations Easy
CSS-only Typewriter
A typewriter animation using only CSS steps() timing function — no JavaScript, no libraries.
css keyframes steps
Targets: HTML
Code
CSS-only Typewriter
A typewriter effect driven entirely by CSS steps() timing — zero JavaScript. The cursor blink is also CSS-only via a separate @keyframes on border-right.
How it works
The trick uses two animations running simultaneously on the text element:
typing— animateswidthfrom0to100%usingsteps(N)where N = character count.overflow: hiddenclips the text as it types.blink— togglesborder-right-colorbetween the accent color and transparent for the cursor.
@keyframes typing { from { width: 0 } to { width: 100% } }
@keyframes blink { 50% { border-right-color: transparent } }
Limitations
- Works best with monospace fonts (character widths are equal)
- The step count must match the character count exactly
- Multi-line requires JS or separate elements per line
Variants
- Add
animation-iteration-count: infiniteto loop - Chain multiple lines with
animation-delay