Skip to main content
Home / Code Snippets / CSS / Typewriter Effect
.typewriter h1 {
  overflow: hidden; /* Ensures the content is not revealed until the animation */
  border-right: .15em solid orange; /* The typwriter cursor */
  white-space: nowrap; /* Keeps the content on a single line */
  margin: 0 auto; /* Gives that scrolling effect as the typing happens */
  letter-spacing: .15em; /* Adjust as needed */
    typing 3.5s steps(40, end),
    blink-caret .75s step-end infinite;

/* The typing effect */
@keyframes typing {
  from { width: 0 }
  to { width: 100% }

/* The typewriter cursor effect */
@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: orange; }

See the Pen jrWwWM by Geoff Graham (@geoffgraham) on CodePen.


  • Demo relies on flexbox, so that could affect the layout in testing
  • Assumes the use of Autoprefixer
  • The width of the text container will be determined by the length of the text being used
  • Adding more steps to the typing animation will increase the smoothness of the typing
  • Adjust the letter-spacing based on the font-family and font-size being used


Some use JavaScript, which may sometimes be preferable (literally adding a character at a time feels more like a real typewriter) and sometimes not be (potential accessibility concerns).

See the Pen Typewriter animation pure CSS by Thiago Teles Pereira (@thiagoteles) on CodePen.

See the Pen JS Typewriter by Simon Shahriveri (@hi-im-si) on CodePen.

See the Pen typewriter by gavra (@gavra) on CodePen.

See the Pen CSS typewriter by Danielgroen (@danielgroen) on CodePen.

See the Pen Tippy-tappy-typer by Stove (@stevn) on CodePen.

See the Pen CSS Typing Multiple Lines with Blinking Caret by Joeri Boudewijns (@Bojoer) on CodePen.