CSS Typing Effect – Create a Typewriter Animation with Pure CSS

Follow for more stuff

The typing effect simulates a typewriter. Characters appear one by one while a caret blinks at the end. You can build it with pure CSS using width animation and a border based cursor.

What we are building

We create a headline or short sentence that types itself. The caret blinks to reinforce the illusion. No JavaScript is required. The trick is a masked line that grows from 0 to the full text width.

Core CSS

Use two animations. The first controls the reveal using steps. The second toggles the caret visibility.

.typing-text{
  white-space: nowrap;
  overflow: hidden;
  border-right: .15em solid crimson;
  animation: typing 4s steps(22, end) infinite, blink .75s step-end infinite;
}

@keyframes typing{
  from{ width: 0 }
  to{ width: 22ch }
}

@keyframes blink{
  from, to{ border-color: transparent }
  50%{ border-color: crimson }
}

How it works

Customization tips

Accessibility notes

Keep sentences short so users can read them easily. If motion is an issue, respect reduced motion preferences.

@media (prefers-reduced-motion: reduce){
  .typing-text{ animation: none; border-right: 0 }
}

Wrap-up

A clean typing effect needs only CSS. Animate width in steps for the characters. Blink the caret with a simple keyframe. The result is light, readable, and perfect for hero sections and callouts.